-
Notifications
You must be signed in to change notification settings - Fork 11.7k
fix: return 400 instead of 500 for invalid email in iCal generation #27217
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
Conversation
Co-Authored-By: benny@cal.com <sldisek783@gmail.com>
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
Co-Authored-By: benny@cal.com <sldisek783@gmail.com>
E2E results are ready! |
| // The ics library throws Yup ValidationError objects (not Error instances) for invalid data like invalid email formats. | ||
| // Convert these to ErrorWithCode.BadRequest so they return 400 instead of falling through to a generic 500. | ||
| if (icsEvent.error.name === "ValidationError") { | ||
| throw new ErrorWithCode(ErrorCode.BadRequest, icsEvent.error.message); |
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.
this propagates all the way to getServerErrorFromUnknown, at which this gets converted into HttpError with status code 400
| // Simulate a Yup ValidationError (which has name: "ValidationError") | ||
| const validationError = { | ||
| name: "ValidationError", | ||
| message: "attendees[0].email must be a valid email", | ||
| errors: ["attendees[0].email must be a valid email"], | ||
| }; |
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.
I confirmed that ics library throws a validation error in this format
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.
No issues found across 2 files
emrysal
left a comment
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.
Looks good! No comments, good to go
What does this PR do?
Fixes a 500 error that occurs when rescheduling phone-only bookings.
Request path:
The
icslibrary throws a Yup ValidationError when an attendee has a phone number instead of an email. Since Yup ValidationError is not anErrorinstance, it falls through error handling to a generic 500.Fix: Catch the ValidationError at the source (
generateIcsString.ts) and convert it toErrorWithCode.BadRequest, returning a proper 400 status code.Mandatory Tasks (DO NOT REMOVE)