Skip to content

Commit

Permalink
Fix 400 yoga errors being sent to exception handlers (twentyhq#5322)
Browse files Browse the repository at this point in the history
## Context
Yoga can catch its own errors and we don't want to convert them again.
Moreover those errors don't have an "originalError" property and should
be schema related only (400 validation) so we only want to send them
back to the API caller without going through the exception handler.

Also fixed an issue in the createMany which was throwing a 500 when id
was missing from the creation payload. It seems the FE is always sending
an ID but it should actually be optional since the DB can generate one.
This is a regression from the new UUID validation introduced a few weeks
ago.
  • Loading branch information
Weiko committed May 7, 2024
1 parent 6edecf7 commit e802cef
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ export class WorkspaceQueryRunnerService {
assertMutationNotOnRemoteObject(objectMetadataItem);

args.data.forEach((record) => {
if (record.id) {
if (record?.id) {
assertIsValidUuid(record.id);
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,11 @@ export const useExceptionHandler = <PluginContext extends GraphQLContext>(
...exceptions.unfiltered,
];
const errors = concatenatedErrors.map((err) => {
// Properly convert errors to GraphQLErrors
const graphQLError = convertExceptionToGraphQLError(
err.originalError,
);
if (!err.originalError) {
return err;
}

return graphQLError;
return convertExceptionToGraphQLError(err.originalError);
});

setResult({
Expand Down

0 comments on commit e802cef

Please sign in to comment.