From c1c0a37d7bb71581f85b62f8ed16c3c77b5e2d9d Mon Sep 17 00:00:00 2001 From: Steph Date: Wed, 1 Oct 2025 15:07:04 +0200 Subject: [PATCH 1/2] update list result validation to check if identity is fully null --- internal/fwserver/server_listresource.go | 5 ++- internal/fwserver/server_listresource_test.go | 36 +++++++++++++++++++ 2 files changed, 38 insertions(+), 3 deletions(-) diff --git a/internal/fwserver/server_listresource.go b/internal/fwserver/server_listresource.go index 828382338..c567259c2 100644 --- a/internal/fwserver/server_listresource.go +++ b/internal/fwserver/server_listresource.go @@ -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 { @@ -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", ) } diff --git a/internal/fwserver/server_listresource_test.go b/internal/fwserver/server_listresource_test.go index 5c4315b94..e26ced636 100644 --- a/internal/fwserver/server_listresource_test.go +++ b/internal/fwserver/server_listresource_test.go @@ -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 { From 11eeb65f2f5da7d39a1bffe246f84df835157545 Mon Sep 17 00:00:00 2001 From: Steph Date: Wed, 1 Oct 2025 15:23:12 +0200 Subject: [PATCH 2/2] add changelog --- .changes/unreleased/BUG FIXES-20251001-152300.yaml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changes/unreleased/BUG FIXES-20251001-152300.yaml diff --git a/.changes/unreleased/BUG FIXES-20251001-152300.yaml b/.changes/unreleased/BUG FIXES-20251001-152300.yaml new file mode 100644 index 000000000..677ffc070 --- /dev/null +++ b/.changes/unreleased/BUG FIXES-20251001-152300.yaml @@ -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"