-
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
Better errors handling #8835
Better errors handling #8835
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
This PR improves error handling across the server, particularly focusing on environment variable configuration issues and error tracking.
- Introduced new
EnvironmentException
to properly handle missing environment variables instead of generic auth errors - Added workspace context (id, displayName, activationStatus) to error tracking for better debugging in Sentry
- Simplified exception handler interface by removing
captureMessage
method to focus on exception capture - Updated cron jobs to use workspace-based error reporting instead of user-based format
- Improved schema version validation to prevent client-server mismatches in GraphQL requests
26 file(s) reviewed, 6 comment(s)
Edit PR Review Bot Settings | Greptile
canActivate(): boolean | Promise<boolean> | Observable<boolean> { | ||
if (!this.environmentService.get('AUTH_GOOGLE_ENABLED')) { | ||
throw new AuthException( | ||
throw new EnvironmentException( | ||
'Google auth is not enabled', | ||
AuthExceptionCode.FORBIDDEN_EXCEPTION, | ||
EnvironmentExceptionCode.ENVIRONMENT_VARIABLES_NOT_FOUND, | ||
); | ||
} |
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.
style: consider adding workspace info to error context for better debugging, as mentioned in PR requirements
canActivate(): boolean | Promise<boolean> | Observable<boolean> { | ||
if (!this.environmentService.get('ENTERPRISE_KEY')) { | ||
throw new AuthException( | ||
throw new EnvironmentException( | ||
'Enterprise key must be defined to use SSO', | ||
AuthExceptionCode.FORBIDDEN_EXCEPTION, | ||
EnvironmentExceptionCode.ENVIRONMENT_VARIABLES_NOT_FOUND, | ||
); | ||
} |
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.
style: Consider adding a check for AUTH_SSO_ENABLED in addition to ENTERPRISE_KEY to maintain consistency with other provider guards
import { CustomException } from 'src/utils/custom-exception'; | ||
|
||
export class EnvironmentException extends CustomException { | ||
code: EnvironmentExceptionCode; |
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.
style: code property should be readonly since it's only set in constructor
...es/twenty-server/src/engine/core-modules/auth/guards/google-apis-oauth-request-code.guard.ts
Outdated
Show resolved
Hide resolved
...r/src/engine/core-modules/exception-handler/interfaces/exception-handler-driver.interface.ts
Show resolved
Hide resolved
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.
LGTM for sharing workspace details with sentry! Left a few comments though but this can be discussed after the fix
...erver/src/engine/core-modules/auth/guards/google-apis-oauth-exchange-code-for-token.guard.ts
Show resolved
Hide resolved
packages/twenty-server/src/engine/core-modules/auth/token/services/access-token.service.ts
Show resolved
Hide resolved
Thanks @guillim for your contribution! |
follow up on #8845 |
- [ ] Catch this specific `500` error - [ ] Make sure catched `500` errors are sent to sentry for the Cloud version - [ ] Hide the option to sync email with google in this situation where the according env var is missing - [x] Add Worskpace information to all catched errors for better debugging fix twentyhq#8607
500
error500
errors are sent to sentry for the Cloud versionfix #8607