Skip to content

Commit 7dce0b7

Browse files
committed
ListResource: tidy diagnostic messages
1 parent 9cafd72 commit 7dce0b7

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

internal/fwserver/server_listresource.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,15 +130,19 @@ func processListResult(req list.ListRequest, result list.ListResult) ListResult
130130
if result.Identity == nil { // TODO: is result.Identity.Raw.IsNull() a practical concern?
131131
return ListResultError(
132132
"Incomplete List Result",
133-
"The provider did not populate the Identity field in the ListResourceResult. This may be due to an error in the provider's implementation.",
133+
"When listing resources, an implementation issue was found. "+
134+
"This is always a problem with the provider. Please report this to the provider developers.\n\n"+
135+
"The \"Identity\" field is nil.\n\n",
134136
)
135137
}
136138

137139
if req.IncludeResource {
138140
if result.Resource == nil { // TODO: is result.Resource.Raw.IsNull() a practical concern?
139141
result.Diagnostics.AddWarning(
140142
"Incomplete List Result",
141-
"The provider did not populate the Resource field in the ListResourceResult. This may be due to the provider not supporting this functionality or an error in the provider's implementation.",
143+
"When listing resources, an implementation issue was found. "+
144+
"This is always a problem with the provider. Please report this to the provider developers.\n\n"+
145+
"The \"IncludeResource\" field in the ListRequest is true, but the \"Resource\" field in the ListResult is nil.\n\n",
142146
)
143147
}
144148
}

internal/fwserver/server_listresource_test.go

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ func TestServerListResource(t *testing.T) {
208208
Diagnostics: diag.Diagnostics{
209209
diag.NewErrorDiagnostic(
210210
"Incomplete List Result",
211-
"The provider did not populate the Identity field in the ListResourceResult. This may be due to an error in the provider's implementation.",
211+
"The provider did not populate the Identity field in the ListResourceResult. This is always a problem with the provider. Please report this to the provider developer.",
212212
),
213213
},
214214
},
@@ -264,8 +264,19 @@ func TestServerListResource(t *testing.T) {
264264
t.Fatalf("unexpected error: %s", err)
265265
}
266266

267+
opts := cmp.Options{
268+
cmp.Comparer(func(a, b diag.Diagnostics) bool {
269+
// Differences in Detail() are not relevant to correctness of logic
270+
for i := range a {
271+
if a[i].Severity() != b[i].Severity() || a[i].Summary() != b[i].Summary() {
272+
return false
273+
}
274+
}
275+
return true
276+
}),
277+
}
267278
events := slices.AppendSeq([]fwserver.ListResult{}, response.Results)
268-
if diff := cmp.Diff(events, testCase.expectedStreamEvents); diff != "" {
279+
if diff := cmp.Diff(events, testCase.expectedStreamEvents, opts); diff != "" {
269280
t.Errorf("unexpected difference: %s", diff)
270281
}
271282
})

0 commit comments

Comments
 (0)