Skip to content

Conversation

@hbjORbj
Copy link
Contributor

@hbjORbj hbjORbj commented Nov 17, 2025

What does this PR do?

Fixes 500 errors on api/book/event endpoint when the ics library throws Yup ValidationErrors during calendar file generation. This occurs when attendees have invalid email addresses (e.g., street addresses instead of emails).

Problem: The ics library (v2.37.0) uses Yup for validation. When generating ICS calendar files with invalid attendee emails, it throws a ValidationError that wasn't recognized by getServerErrorFromUnknown, causing it to fall through to the generic handler and return 500 status instead of 400.

Solution: Add Yup ValidationError detection and handling to return proper 400 status codes with validation error messages.

Mandatory Tasks (DO NOT REMOVE)

  • I have self-reviewed the code
  • I have updated the developer docs in /docs if this PR makes changes that would require a documentation change. N/A - internal error handling change
  • I confirm automated tests are in place that prove my fix is effective or that my feature works

Link to Devin run: https://app.devin.ai/sessions/80180c74544745e78b2d5fee68a10fca
Requested by: [email protected] (@hbjORbj)

Add support for Yup ValidationError thrown by the ics library when
generating calendar files with invalid attendee emails. This prevents
500 errors and returns proper 400 status codes with validation messages.

The ics library uses Yup for validation, and when attendee emails are
invalid (e.g., street addresses instead of emails), it throws a
ValidationError that was not being caught by getServerErrorFromUnknown.

Changes:
- Add isYupValidationError type guard to detect Yup ValidationErrors
- Add parseYupValidationErrors to extract error messages from inner array
- Handle Yup ValidationError in getServerErrorFromUnknown, returning 400 status

Co-Authored-By: [email protected] <[email protected]>
@devin-ai-integration
Copy link
Contributor

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR that start with 'DevinAI' or '@devin'.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@vercel
Copy link

vercel bot commented Nov 18, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

2 Skipped Deployments
Project Deployment Preview Comments Updated (UTC)
cal Ignored Ignored Nov 18, 2025 0:37am
cal-eu Ignored Ignored Nov 18, 2025 0:37am

@hbjORbj hbjORbj marked this pull request as ready for review November 18, 2025 05:56
@graphite-app graphite-app bot requested a review from a team November 18, 2025 05:56
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 2 files

Prompt for AI agents (all 1 issues)

Understand the root cause of the following 1 issues and fix them.


<file name="packages/lib/server/getServerErrorFromUnknown.ts">

<violation number="1" location="packages/lib/server/getServerErrorFromUnknown.ts:39">
Rule violated: **Enforce Singular Naming for Single-Item Functions**

Rename `parseYupErrors` to a singular form (e.g., `parseYupErrorMessage`) because it returns one string rather than multiple values, in order to comply with the singular-naming rule for single-item functions.</violation>
</file>

Reply to cubic to teach it or ask questions. Re-run a review with @cubic-dev-ai review this PR

Comment on lines +24 to +36
function isYupError(cause: unknown): cause is {
name: string;
message: string;
inner: Array<{ path?: string; message: string; type?: string }>;
errors: string[];
} {
return (
hasName(cause) &&
cause.name === "ValidationError" &&
typeof cause === "object" &&
"inner" in cause &&
Array.isArray((cause as { inner: unknown }).inner)
);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aren't we leaking too much implementation detail in here. TRPCError and HttpError are fine as those are like pretty generic and used everywhere.

Ideally the service/place using ics should handle this error and return appropriate HttpError or some known error may be?

Copy link
Member

@hariombalhara hariombalhara left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have a suggestion

@github-actions
Copy link
Contributor

github-actions bot commented Nov 18, 2025

E2E results are ready!

Copy link
Member

@hariombalhara hariombalhara left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requesting changes, feel free to dismiss if doesn't make sense

@github-actions github-actions bot marked this pull request as draft November 19, 2025 09:38
auto-merge was automatically disabled November 19, 2025 09:38

Pull request was converted to draft

@hbjORbj hbjORbj closed this Nov 21, 2025
@hbjORbj hbjORbj reopened this Nov 21, 2025
@hbjORbj hbjORbj closed this Nov 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants