Return conflict when user has linked records
Map remove-user foreign key failures to a dedicated IAM conflict error so\nconsole users no longer receive a generic internal server error when a\nprofile is still referenced by signed documents, tasks, assets, or\nother records.\n\nThe service now detects wrapped dependency errors across both profile\nand membership deletes, and resolvers explicitly map the new error type\nto conflict responses. Added unit tests cover dependency detection and\nthe user-facing error message. Signed-off-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: Bryan FRIMIN <bryan@frimin.fr>
This commit is contained in:
committed by
Bryan Frimin
parent
a7639be86b
commit
ffa3db3cd2
@@ -2930,6 +2930,10 @@ func (r *Resolver) RemoveUserTool(ctx context.Context, req *mcp.CallToolRequest,
|
||||
return nil, types.RemoveUserOutput{}, fmt.Errorf("cannot remove last active owner: %w", err)
|
||||
}
|
||||
|
||||
if _, ok := errors.AsType[*iam.ErrUserReferencedByRecords](err); ok {
|
||||
return nil, types.RemoveUserOutput{}, fmt.Errorf("cannot remove user: %w", err)
|
||||
}
|
||||
|
||||
if errors.Is(err, coredata.ErrResourceInUse) {
|
||||
return nil, types.RemoveUserOutput{}, fmt.Errorf("cannot remove user: %w", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user