@@ -102,7 +102,6 @@ func TestServerListResource(t *testing.T) {
102102 },
103103 expectedStreamEvents : []fwserver.ListResult {},
104104 },
105-
106105 "success-with-multiple-results" : {
107106 server : & fwserver.Server {
108107 Provider : & testprovider.Provider {},
@@ -166,6 +165,74 @@ func TestServerListResource(t *testing.T) {
166165 },
167166 },
168167 },
168+ "error-on-missing-resource-identity" : {
169+ server : & fwserver.Server {
170+ Provider : & testprovider.Provider {},
171+ },
172+ request : & fwserver.ListRequest {
173+ ListResource : & testprovider.ListResource {
174+ ListMethod : func (ctx context.Context , req list.ListRequest , resp * list.ListResultsStream ) { // TODO
175+ resp .Results = slices .Values ([]list.ListResult {
176+ {
177+ Identity : nil ,
178+ Resource : & tfsdk.Resource {
179+ Schema : testSchema ,
180+ Raw : testResourceValue1 ,
181+ },
182+ DisplayName : "Test Resource 1" ,
183+ },
184+ })
185+ },
186+ },
187+ },
188+ expectedStreamEvents : []fwserver.ListResult {
189+ {
190+ Diagnostics : diag.Diagnostics {
191+ diag .NewErrorDiagnostic (
192+ "Incomplete List Result" ,
193+ "The provider did not populate the Identity field in the ListResourceResult. This may be due to an error in the provider's implementation." ,
194+ ),
195+ },
196+ },
197+ },
198+ },
199+ "warning-on-missing-resource" : {
200+ server : & fwserver.Server {
201+ Provider : & testprovider.Provider {},
202+ },
203+ request : & fwserver.ListRequest {
204+ IncludeResource : true ,
205+ ListResource : & testprovider.ListResource {
206+ ListMethod : func (ctx context.Context , req list.ListRequest , resp * list.ListResultsStream ) {
207+ resp .Results = slices .Values ([]list.ListResult {
208+ {
209+ Identity : & tfsdk.ResourceIdentity {
210+ Schema : testIdentitySchema ,
211+ Raw : testIdentityValue1 ,
212+ },
213+ Resource : nil ,
214+ DisplayName : "Test Resource 1" ,
215+ },
216+ })
217+ },
218+ },
219+ },
220+ expectedStreamEvents : []fwserver.ListResult {
221+ {
222+ Identity : & tfsdk.ResourceIdentity {
223+ Schema : testIdentitySchema ,
224+ Raw : testIdentityValue1 ,
225+ },
226+ DisplayName : "Test Resource 1" ,
227+ Diagnostics : diag.Diagnostics {
228+ diag .NewWarningDiagnostic (
229+ "Incomplete List Result" ,
230+ "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." ,
231+ ),
232+ },
233+ },
234+ },
235+ },
169236 }
170237
171238 for name , testCase := range testCases {
0 commit comments