@@ -164,6 +164,11 @@ func TestServerReadResource(t *testing.T) {
164
164
Schema : testIdentitySchema ,
165
165
}
166
166
167
+ testEmptyIdentity := & tfsdk.ResourceIdentity {
168
+ Schema : testIdentitySchema ,
169
+ Raw : tftypes .NewValue (testIdentitySchema .Type ().TerraformType (context .Background ()), nil ),
170
+ }
171
+
167
172
testNewStateRemoved := & tfsdk.State {
168
173
Raw : tftypes .NewValue (testType , nil ),
169
174
Schema : testSchema ,
@@ -636,6 +641,35 @@ func TestServerReadResource(t *testing.T) {
636
641
Private : testEmptyPrivate ,
637
642
},
638
643
},
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
+ },
639
673
"response-identity-valid-update-null-currentidentity" : {
640
674
server : & fwserver.Server {
641
675
Provider : & testprovider.Provider {},
0 commit comments