Skip to content

Commit 0abbf5a

Browse files
committed
Fixing the pipeline
1 parent b4f6945 commit 0abbf5a

File tree

2 files changed

+23
-6
lines changed

2 files changed

+23
-6
lines changed

internal/fwserver/server_moveresourcestate.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,16 @@ func (s *Server) MoveResourceState(ctx context.Context, req *MoveResourceStateRe
226226
return
227227
}
228228

229+
if resp.TargetIdentity != nil && req.IdentitySchema == nil {
230+
resp.Diagnostics.AddError(
231+
"Unexpected Move State Response",
232+
"An unexpected error was encountered when creating the move state response. New identity data was returned by the provider move state operation, but the resource does not indicate identity support.\n\n"+
233+
"This is always a problem with the provider and should be reported to the provider developer.",
234+
)
235+
236+
return
237+
}
238+
229239
// Set any write-only attributes in the move resource state to null
230240
modifiedState, err := tftypes.Transform(moveStateResp.TargetState.Raw, NullifyWriteOnlyAttributes(ctx, moveStateResp.TargetState.Schema))
231241
if err != nil {

internal/fwserver/server_moveresourcestate_test.go

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -961,12 +961,19 @@ func TestServerMoveResourceState(t *testing.T) {
961961
TargetTypeName: "test_resource",
962962
},
963963
expectedResponse: &fwserver.MoveResourceStateResponse{
964-
Diagnostics: diag.Diagnostics{
965-
diag.NewErrorDiagnostic(
966-
"Unexpected Move State Response",
967-
"An unexpected error was encountered when creating the move state response. Identity data was returned by the provider move state operation, but the resource does not indicate identity support.\n\n"+
968-
"This is always a problem with the provider and should be reported to the provider developer.",
969-
),
964+
TargetState: &tfsdk.State{
965+
Raw: tftypes.NewValue(schemaType, map[string]tftypes.Value{
966+
"id": tftypes.NewValue(tftypes.String, "test-id-value"),
967+
"optional_attribute": tftypes.NewValue(tftypes.String, nil),
968+
"required_attribute": tftypes.NewValue(tftypes.String, "true"),
969+
}),
970+
Schema: testSchema,
971+
},
972+
TargetIdentity: &tfsdk.ResourceIdentity{
973+
Raw: tftypes.NewValue(schemaIdentityType, map[string]tftypes.Value{
974+
"test_id": tftypes.NewValue(tftypes.String, "should-not-be-set"),
975+
}),
976+
Schema: testIdentitySchema,
970977
},
971978
TargetPrivate: privatestate.EmptyData(ctx),
972979
},

0 commit comments

Comments
 (0)