-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix custom errors thrown as 500 #6238
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Summary
- Updated
packages/twenty-server/src/engine/utils/global-exception-handler.util.ts
to handleBaseGraphQLError
directly. - Prevented fallback to HTTP 500 for custom GraphQL errors.
- Ensured custom GraphQL errors return intended status codes.
1 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Summary
(updates since last review)
- Excluded 'Link' field type in
StyledSettingsObjectFieldTypeSelect
in/packages/twenty-front/src/pages/settings/data-model/SettingsObjectFieldEdit.tsx
- Uncommented 'Link' field type in exclusion list in
/packages/twenty-front/src/pages/settings/data-model/SettingsObjectNewField/SettingsObjectNewFieldStep2.tsx
- Added validation to deprecate 'LINK' field types in
/packages/twenty-server/src/engine/metadata-modules/field-metadata/field-metadata.service.ts
- Reordered imports for better organization in
/packages/twenty-server/src/engine/metadata-modules/field-metadata/field-metadata.service.ts
3 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Summary
(updates since last review)
- Replaced
useExceptionHandler
withuseGraphQLErrorHandlerHook
in/packages/twenty-server/src/engine/api/graphql/metadata.module-factory.ts
- Introduced
EngineGraphQLModule
in/packages/twenty-server/src/engine/core-modules/graphql/engine-graphql.module.ts
- Added
useGraphQLErrorHandlerHook
in/packages/twenty-server/src/engine/core-modules/graphql/hooks/use-graphql-error-handler.hook.ts
- Added
generateGraphQLErrorFromError
utility in/packages/twenty-server/src/engine/core-modules/graphql/utils/generate-graphql-error-from-error.util.ts
- Updated exception handling logic across multiple files to prevent custom GraphQL errors from defaulting to 500 errors
16 file(s) reviewed, 1 comment(s)
Edit PR Review Bot Settings
graphqlError.extensions['response'] = error.message; | ||
} | ||
|
||
return error; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧠 logic: Should return graphqlError
instead of error
to ensure the converted error is returned.
We call convertExceptionToGraphQLError in the exception handler for http exceptions but we don't take into account those that already are graphqlErrors and because of that the logic of convertExceptionToGraphql is to fallback to a 500.
Now if the exception is a BaseGraphqlError (custom graphql error we throw in the code), we throw them directly.
BEFORE
AFTER