Return clear error on user delete FK violation
Deleting a membership profile referenced by other tables (owner, approver, assignee, etc.) surfaced as a generic Internal error. Detect the Postgres FK violation (23503) in the coredata Delete, return ErrResourceInUse, and map it to CONFLICT in the GraphQL and MCP resolvers so the client sees an actionable error. Signed-off-by: Sacha Al Himdani <sacha@getprobo.com>
This commit is contained in:
@@ -120,6 +120,10 @@ func (r *mutationResolver) RemoveUser(ctx context.Context, input types.RemoveUse
|
||||
return nil, gqlutils.Conflict(ctx, err)
|
||||
}
|
||||
|
||||
if errors.Is(err, coredata.ErrResourceInUse) {
|
||||
return nil, gqlutils.Conflict(ctx, err)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot remove user from organization", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
|
||||
Reference in New Issue
Block a user