Skip to content

Commit 8855023

Browse files
authored
list: update list result validation to check if identity is fully null (#1230)
* update list result validation to check if identity is fully null * add changelog
1 parent 6d2ebde commit 8855023

File tree

3 files changed

+43
-3
lines changed

3 files changed

+43
-3
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
kind: BUG FIXES
2+
body: 'fwserver: update validation list result validation to check if an identity''s values are all null'
3+
time: 2025-10-01T15:23:00.976476+02:00
4+
custom:
5+
Issue: "1230"

internal/fwserver/server_listresource.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@ func (s *Server) ListResource(ctx context.Context, fwReq *ListRequest, fwStream
100100
}
101101
}
102102

103-
// TODO verdict is still out on how to handle diagnostics that pertain to the List call as a whole and not individual list results
104103
diagsStream := &list.ListResultsStream{}
105104

106105
if listResourceWithConfigure, ok := listResource.(list.ListResourceWithConfigure); ok {
@@ -191,12 +190,12 @@ func processListResult(req list.ListRequest, result list.ListResult) ListResult
191190
return ListResult(result)
192191
}
193192

194-
if result.Identity == nil || result.Identity.Raw.IsNull() {
193+
if result.Identity == nil || result.Identity.Raw.IsFullyNull() {
195194
return ListResultError(
196195
"Incomplete List Result",
197196
"When listing resources, an implementation issue was found. "+
198197
"This is always a problem with the provider. Please report this to the provider developers.\n\n"+
199-
"The \"Identity\" field is nil.\n\n",
198+
"The \"Identity\" field is nil or the values are nil.\n\n",
200199
)
201200
}
202201

internal/fwserver/server_listresource_test.go

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,42 @@ func TestServerListResource(t *testing.T) {
250250
},
251251
expectedStreamEvents: []fwserver.ListResult{},
252252
},
253+
"null-identity": {
254+
server: &fwserver.Server{
255+
Provider: &testprovider.Provider{},
256+
},
257+
request: &fwserver.ListRequest{
258+
Config: &tfsdk.Config{},
259+
ListResource: &testprovider.ListResource{
260+
ListMethod: func(ctx context.Context, req list.ListRequest, resp *list.ListResultsStream) {
261+
resp.Results = slices.Values([]list.ListResult{
262+
{
263+
Identity: &tfsdk.ResourceIdentity{
264+
Schema: testIdentitySchema,
265+
Raw: tftypes.NewValue(testIdentityType, map[string]tftypes.Value{
266+
"test_id": tftypes.NewValue(tftypes.String, nil),
267+
}),
268+
},
269+
Resource: &tfsdk.Resource{
270+
Schema: testSchema,
271+
Raw: testResourceValue1,
272+
},
273+
DisplayName: "Test Resource 1",
274+
Diagnostics: diag.Diagnostics{},
275+
},
276+
})
277+
},
278+
},
279+
},
280+
expectedStreamEvents: []fwserver.ListResult{
281+
{
282+
DisplayName: "",
283+
Diagnostics: diag.Diagnostics{
284+
diag.NewErrorDiagnostic("Incomplete List Result", "When listing resources, an implementation issue was found. This is always a problem with the provider. Please report this to the provider developers.\n\nThe \"Identity\" field is nil or the values are nil.\n\n"),
285+
},
286+
},
287+
},
288+
},
253289
}
254290

255291
for name, testCase := range testCases {

0 commit comments

Comments
 (0)