Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changes/unreleased/BUG FIXES-20251001-152300.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
kind: BUG FIXES
body: 'fwserver: update validation list result validation to check if an identity''s values are all null'
time: 2025-10-01T15:23:00.976476+02:00
custom:
Issue: "1230"
5 changes: 2 additions & 3 deletions internal/fwserver/server_listresource.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ func (s *Server) ListResource(ctx context.Context, fwReq *ListRequest, fwStream
}
}

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

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

if result.Identity == nil || result.Identity.Raw.IsNull() {
if result.Identity == nil || result.Identity.Raw.IsFullyNull() {
return ListResultError(
"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\n"+
"The \"Identity\" field is nil.\n\n",
"The \"Identity\" field is nil or the values are nil.\n\n",
)
}

Expand Down
36 changes: 36 additions & 0 deletions internal/fwserver/server_listresource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,42 @@ func TestServerListResource(t *testing.T) {
},
expectedStreamEvents: []fwserver.ListResult{},
},
"null-identity": {
server: &fwserver.Server{
Provider: &testprovider.Provider{},
},
request: &fwserver.ListRequest{
Config: &tfsdk.Config{},
ListResource: &testprovider.ListResource{
ListMethod: func(ctx context.Context, req list.ListRequest, resp *list.ListResultsStream) {
resp.Results = slices.Values([]list.ListResult{
{
Identity: &tfsdk.ResourceIdentity{
Schema: testIdentitySchema,
Raw: tftypes.NewValue(testIdentityType, map[string]tftypes.Value{
"test_id": tftypes.NewValue(tftypes.String, nil),
}),
},
Resource: &tfsdk.Resource{
Schema: testSchema,
Raw: testResourceValue1,
},
DisplayName: "Test Resource 1",
Diagnostics: diag.Diagnostics{},
},
})
},
},
},
expectedStreamEvents: []fwserver.ListResult{
{
DisplayName: "",
Diagnostics: diag.Diagnostics{
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"),
},
},
},
},
}

for name, testCase := range testCases {
Expand Down