feat(server): enforce userFriendlyMessage on all exceptions#16589
feat(server): enforce userFriendlyMessage on all exceptions#16589FelixMalfait merged 3 commits intomainfrom
Conversation
There was a problem hiding this comment.
Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.
There was a problem hiding this comment.
This is the final PR Bugbot will review for you during this billing cycle
Your free Bugbot reviews will reset on January 15
Details
You are on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle.
To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.
packages/twenty-server/src/engine/core-modules/dns-manager/exceptions/dns-manager.exception.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
1 issue found across 88 files
Note: This PR contains a large number of files. cubic only reviews up to 75 files per PR, so some files may not have been reviewed.
Prompt for AI agents (all 1 issues)
Check if these issues are valid — if so, understand the root cause of each and fix them.
<file name="packages/twenty-server/src/engine/metadata-modules/view-filter/filters/view-filter-rest-api-exception.filter.ts">
<violation number="1" location="packages/twenty-server/src/engine/metadata-modules/view-filter/filters/view-filter-rest-api-exception.filter.ts:85">
P2: Use Lingui's `msg` macro instead of a plain object for `userFriendlyMessage`. This ensures the message is picked up by Lingui's extraction process for translation and maintains consistency with other exception classes in the codebase (e.g., `ViewFilterException`).</violation>
</file>
Reply to cubic to teach it or ask questions. Re-run a review with @cubic-dev-ai review this PR
| 'Internal server error', | ||
| 'INTERNAL_ERROR', | ||
| { | ||
| userFriendlyMessage: { |
There was a problem hiding this comment.
P2: Use Lingui's msg macro instead of a plain object for userFriendlyMessage. This ensures the message is picked up by Lingui's extraction process for translation and maintains consistency with other exception classes in the codebase (e.g., ViewFilterException).
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At packages/twenty-server/src/engine/metadata-modules/view-filter/filters/view-filter-rest-api-exception.filter.ts, line 85:
<comment>Use Lingui's `msg` macro instead of a plain object for `userFriendlyMessage`. This ensures the message is picked up by Lingui's extraction process for translation and maintains consistency with other exception classes in the codebase (e.g., `ViewFilterException`).</comment>
<file context>
@@ -81,6 +81,12 @@ export class ViewFilterRestApiExceptionFilter implements ExceptionFilter {
'Internal server error',
'INTERNAL_ERROR',
+ {
+ userFriendlyMessage: {
+ id: 'internal.error',
+ message: 'An unexpected error occurred.',
</file context>
✅ Addressed in 11f589a
11f589a to
7ae1359
Compare
7ae1359 to
eab4e7e
Compare
| USE_SSO_AUTH: msg`Please use single sign-on to authenticate.`, | ||
| SIGNUP_DISABLED: msg`Sign up is disabled.`, | ||
| GOOGLE_API_AUTH_DISABLED: msg`Google API authentication is disabled.`, | ||
| MICROSOFT_API_AUTH_DISABLED: msg`Microsoft API authentication is disabled.`, | ||
| MISSING_ENVIRONMENT_VARIABLE: msg`A required configuration is missing.`, | ||
| INVALID_JWT_TOKEN_TYPE: msg`Invalid authentication token.`, | ||
| TWO_FACTOR_AUTHENTICATION_PROVISION_REQUIRED: msg`Two-factor authentication setup is required.`, | ||
| TWO_FACTOR_AUTHENTICATION_VERIFICATION_REQUIRED: msg`Two-factor authentication verification is required.`, | ||
| USER_ALREADY_EXISTS: msg`A user with this email already exists.`, | ||
| INTERNAL_SERVER_ERROR: msg`An unexpected error occurred.`, | ||
| }; |
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
- Make userFriendlyMessage required in CustomException (no longer optional) - Remove ForceFriendlyMessage generic parameter as it's no longer needed - Update all 74+ exception classes to provide default user-friendly messages - Each exception class now has a sensible default message using Lingui msg macro - This ensures end users always see a readable error message
eab4e7e to
08af613
Compare
📊 API Changes ReportGraphQL Schema ChangesGraphQL Schema Changes[error] Error: Unable to read JSON file: /home/runner/work/twenty/twenty/main-schema-introspection.json: Not valid JSON content GraphQL Metadata Schema ChangesGraphQL Metadata Schema Changes[error] Error: Unable to read JSON file: /home/runner/work/twenty/twenty/main-metadata-schema-introspection.json: Not valid JSON content REST API Analysis ErrorError OutputREST Metadata API Analysis ErrorError Output
|
|
Hey @FelixMalfait! After you've done the QA of your Pull Request, you can mark it as done here. Thank you! |
Summary
This PR enforces that all custom exceptions must provide a
userFriendlyMessage, ensuring end users always see readable error messages.Changes
Core Changes
CustomExceptionsimplified: Removed theForceFriendlyMessagegeneric parameter -userFriendlyMessageis now always required{ userFriendlyMessage: MessageDescriptor }(no longer optional)Updated Files
msgmacromsg\An authentication error occurred.``)Benefits
Testing
npx nx run twenty-server:typecheckpassesnpx nx run twenty-server:lintpassesNote
Enforces
userFriendlyMessageonCustomExceptionand updates all exception classes to supply localized default messages, with filters/tests adjusted accordingly.userFriendlyMessageinCustomException(remove optional generic; constructor now requires{ userFriendlyMessage: MessageDescriptor }).msgmaps and pass them in constructors (e.g.,AuthException,ObjectMetadataException,FieldMetadataException, etc.).INTERNAL_SERVER_ERRORor domain-specific defaults).UnknownExceptionwithmsgfor user-friendly text in REST/GraphQL exception filters.userFriendlyMessageto exceptions.extensions.userFriendlyMessageor message objects where applicable.Written by Cursor Bugbot for commit 221004f. This will update automatically on new commits. Configure here.