@@ -164,6 +164,11 @@ func TestServerReadResource(t *testing.T) {
164164 Schema : testIdentitySchema ,
165165 }
166166
167+ testEmptyIdentity := & tfsdk.ResourceIdentity {
168+ Schema : testIdentitySchema ,
169+ Raw : tftypes .NewValue (testIdentitySchema .Type ().TerraformType (context .Background ()), nil ),
170+ }
171+
167172 testNewStateRemoved := & tfsdk.State {
168173 Raw : tftypes .NewValue (testType , nil ),
169174 Schema : testSchema ,
@@ -636,6 +641,35 @@ func TestServerReadResource(t *testing.T) {
636641 Private : testEmptyPrivate ,
637642 },
638643 },
644+ "response-invalid-nil-identity" : {
645+ server : & fwserver.Server {
646+ Provider : & testprovider.Provider {},
647+ },
648+ request : & fwserver.ReadResourceRequest {
649+ CurrentState : testCurrentState ,
650+ CurrentIdentity : nil ,
651+ IdentitySchema : testIdentitySchema ,
652+ Resource : & testprovider.ResourceWithIdentity {
653+ Resource : & testprovider.Resource {
654+ ReadMethod : func (ctx context.Context , req resource.ReadRequest , resp * resource.ReadResponse ) {
655+ resp .Identity = req .Identity
656+ },
657+ },
658+ },
659+ },
660+ expectedResponse : & fwserver.ReadResourceResponse {
661+ Diagnostics : diag.Diagnostics {
662+ diag .NewErrorDiagnostic (
663+ "Missing Resource Identity After Read" ,
664+ "The Terraform Provider unexpectedly returned no resource identity data after having no errors in the resource read. " +
665+ "This is always an issue in the Terraform Provider and should be reported to the provider developers." ,
666+ ),
667+ },
668+ NewState : testCurrentState ,
669+ NewIdentity : testEmptyIdentity ,
670+ Private : testEmptyPrivate ,
671+ },
672+ },
639673 "response-identity-valid-update-null-currentidentity" : {
640674 server : & fwserver.Server {
641675 Provider : & testprovider.Provider {},
0 commit comments