fix(calendar): handle not-connected gracefully without throwing#855
Open
AggManik wants to merge 2 commits into
Open
fix(calendar): handle not-connected gracefully without throwing#855AggManik wants to merge 2 commits into
AggManik wants to merge 2 commits into
Conversation
- New native widget CalendarWidget renders today's events sorted by start time, with all-day events at the top - New API route GET /api/v1/calendar/today-events fetches events via the google-calendar integration using the user's local timezone - Registers "calendar" in NATIVE_WIDGETS so users can add it via the widget picker in the Daily section - Updates google-calendar list_events to return structured JSON instead of a formatted string so the route can parse event objects cleanly Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…out throwing - Guard against undefined workspaceId (possible for JWT/API-key auth) by returning connected:false instead of passing undefined to Prisma which can throw a validation error in strict mode - Wrap getConnectedIntegrationAccounts in try-catch so any DB error returns connected:false rather than propagating a 500 that the widget misreads as connected:true - Short-circuit on result.isError before attempting JSON.parse so explicit integration error responses return the correct error state Fixes: calendar widget shows "Could not load events" instead of "Connect Google Calendar" when calendar is not connected Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
undefinedworkspaceId (JWT/API-key auth does not always include workspace context). Previously theas stringcast letundefinedreach Prisma, which can throw a validation error in strict mode — causing the widget to show "Could not load events" instead of "Connect Google Calendar".getConnectedIntegrationAccountsin try-catch so any unexpected DB error returnsconnected: falserather than propagating a 500 that the widget misreads asconnected: true.result.isErrorbeforeJSON.parseso explicit integration error responses set the correct error state.Before
When Google Calendar was not connected (and
workspaceIdwasundefinedin auth context), the route threw → widget catch setconnected: true, error: true→ showed "Could not load events" instead of "Connect Google Calendar".After
All three failure modes (
workspaceIdmissing, DB error, no accounts) return{ connected: false }, which the widget renders as the proper not-connected empty state.Test plan
{ connected: false }HTTP 200, not 500🤖 Generated with Claude Code