Skip to content
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

Merged
merged 5 commits into from
Dec 3, 2024
Merged

Better errors handling #8835

merged 5 commits into from
Dec 3, 2024

Conversation

guillim
Copy link
Contributor

@guillim guillim commented Dec 2, 2024

  • 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
  • Add Worskpace information to all catched errors for better debugging

fix #8607

@guillim guillim requested a review from charlesBochet December 2, 2024 15:00
@guillim guillim added -PR: wip scope: backend Issues that are affecting the backend side only type: chore prio: high labels Dec 2, 2024
@guillim guillim self-assigned this Dec 2, 2024
@guillim guillim marked this pull request as ready for review December 2, 2024 17:29
Copy link
Contributor

@greptile-apps greptile-apps bot left a 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

Comment on lines 16 to 22
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,
);
}
Copy link
Contributor

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

Comment on lines 17 to 23
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,
);
}
Copy link
Contributor

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;
Copy link
Contributor

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

@twentyhq twentyhq deleted a comment from greptile-apps bot Dec 2, 2024
@twentyhq twentyhq deleted a comment from greptile-apps bot Dec 2, 2024
@twentyhq twentyhq deleted a comment from greptile-apps bot Dec 2, 2024
Copy link
Member

@Weiko Weiko left a 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

@Weiko Weiko merged commit 7e4277f into main Dec 3, 2024
19 checks passed
@Weiko Weiko deleted the fix-8607 branch December 3, 2024 11:16
Copy link

github-actions bot commented Dec 3, 2024

Thanks @guillim for your contribution!
This marks your 13th PR on the repo. You're top 3% of all our contributors 🎉
See contributor page - Share on LinkedIn - Share on Twitter

Contributions

@guillim guillim restored the fix-8607 branch December 3, 2024 13:22
@guillim guillim deleted the fix-8607 branch December 4, 2024 10:54
@guillim
Copy link
Contributor Author

guillim commented Dec 4, 2024

follow up on #8845

@guillim guillim removed the -PR: wip label Dec 4, 2024
mdrazak2001 pushed a commit to mdrazak2001/twenty that referenced this pull request Dec 4, 2024
- [ ] 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
prio: high scope: backend Issues that are affecting the backend side only type: chore
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

Server crash if 500 is thrown
2 participants