@@ -927,6 +927,58 @@ func TestServerUpdateResource(t *testing.T) {
927927 Private : testEmptyPrivate ,
928928 },
929929 },
930+ "response-new-identity-nil" : {
931+ server : & fwserver.Server {
932+ Provider : & testprovider.Provider {},
933+ },
934+ request : & fwserver.UpdateResourceRequest {
935+ PlannedState : & tfsdk.Plan {
936+ Raw : tftypes .NewValue (testSchemaType , map [string ]tftypes.Value {
937+ "test_computed" : tftypes .NewValue (tftypes .String , nil ),
938+ "test_required" : tftypes .NewValue (tftypes .String , "test-plannedstate-value" ),
939+ }),
940+ Schema : testSchema ,
941+ },
942+ PlannedIdentity : & tfsdk.ResourceIdentity {
943+ Raw : tftypes .NewValue (testIdentityType , nil ),
944+ Schema : testIdentitySchema ,
945+ },
946+ IdentitySchema : testIdentitySchema ,
947+ ResourceSchema : testSchema ,
948+ Resource : & testprovider.ResourceWithIdentity {
949+ Resource : & testprovider.Resource {
950+ UpdateMethod : func (ctx context.Context , req resource.UpdateRequest , resp * resource.UpdateResponse ) {
951+ var data testSchemaData
952+ resp .Diagnostics .Append (req .Plan .Get (ctx , & data )... )
953+ resp .Diagnostics .Append (resp .State .Set (ctx , & data )... )
954+
955+ resp .Identity .Raw = tftypes .NewValue (testIdentityType , nil )
956+
957+ },
958+ },
959+ },
960+ },
961+ expectedResponse : & fwserver.UpdateResourceResponse {
962+ Diagnostics : []diag.Diagnostic {
963+ diag .NewErrorDiagnostic (
964+ "Missing Resource Identity After Update" ,
965+ "The Terraform Provider unexpectedly returned no resource identity data after having no errors in the resource update. This is always an issue in the Terraform Provider and should be reported to the provider developers." ,
966+ ),
967+ },
968+ NewIdentity : & tfsdk.ResourceIdentity {
969+ Raw : tftypes .NewValue (testIdentityType , nil ),
970+ Schema : testIdentitySchema ,
971+ },
972+ NewState : & tfsdk.State {
973+ Raw : tftypes .NewValue (testSchemaType , map [string ]tftypes.Value {
974+ "test_computed" : tftypes .NewValue (tftypes .String , nil ),
975+ "test_required" : tftypes .NewValue (tftypes .String , "test-plannedstate-value" ),
976+ }),
977+ Schema : testSchema ,
978+ },
979+ Private : testEmptyPrivate ,
980+ },
981+ },
930982 "response-new-identity-null" : {
931983 server : & fwserver.Server {
932984 Provider : & testprovider.Provider {},
@@ -963,6 +1015,12 @@ func TestServerUpdateResource(t *testing.T) {
9631015 },
9641016 },
9651017 expectedResponse : & fwserver.UpdateResourceResponse {
1018+ Diagnostics : []diag.Diagnostic {
1019+ diag .NewErrorDiagnostic (
1020+ "Missing Resource Identity After Update" ,
1021+ "The Terraform Provider unexpectedly returned no resource identity data after having no errors in the resource update. This is always an issue in the Terraform Provider and should be reported to the provider developers." ,
1022+ ),
1023+ },
9661024 NewIdentity : & tfsdk.ResourceIdentity {
9671025 Raw : tftypes .NewValue (testIdentityType , map [string ]tftypes.Value {
9681026 "test_id" : tftypes .NewValue (tftypes .String , nil ),
0 commit comments