fix(web): stop 404 signout on post-signup sync and tolerate cache-only local edits#2195
Merged
tyler-dane merged 1 commit intoJul 19, 2026
Merged
Conversation
…y local edits The event-runtime cutover (#2017) introduced two offline-handling bugs: - syncLocalEventsToCloud fell back to a client-generated sentinel calendar id when no server-side local calendar was found, so the POST /event 404'd with CALENDAR_NOT_FOUND. handleErrorResponse then treated that 404 as an auth failure and signed the just-signed-up user out. Now the sync only targets the real server local calendar and otherwise keeps records on-device for a later sync; a 404 on a data endpoint no longer forces sign-out (only GONE/UNAUTHORIZED do). - Editing an event whose id lives only in the react-query cache (e.g. a materialized recurring-occurrence instance) but not in IndexedDB threw "Event not found" from LocalEventRepository. replace now upserts instead of throwing, so offline edits persist rather than crashing. Generated-By: PostHog Code Task-Id: 3b0e5f4a-eb9c-4db7-8522-feeb18b17dc8
tyler-dane
marked this pull request as ready for review
July 19, 2026 03:27
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
Fixes two offline-handling regressions introduced by the event-runtime cutover to calendar-owned contracts (#2017):
Post-signup sync 404 → surprise sign-out.
syncLocalEventsToCloudfell back to a client-generated sentinel calendar id when it couldn't find a server-side local calendar, thenPOST /eventagainst it. The backend can't resolve that id and throwsCALENDAR_NOT_FOUND(404).handleErrorResponsetreated a 404 on a data endpoint as an auth failure and signed the user out — right after they signed up. Now the sync only ever targets the real server local calendar; if it isn't available yet, the records stay on-device (untouched) for a later sync instead of being pushed with a bogus id. Separately, a 404 on a non-auth endpoint no longer forces sign-out — only genuine session failures (GONE/UNAUTHORIZED) do.Event not foundwhen editing offline. The optimistic layer resolves the edit target from the react-query cache, butLocalEventRepositoryreads IndexedDB. An id present in the cache but absent from the store (e.g. a materialized recurring-occurrence instance) threwEvent not found.replacenow upserts instead of throwing, so the edit persists rather than crashing.Simplicity
Changes are minimal and local to the three affected modules: drop the sentinel fallback in the sync util, remove
NOT_FOUNDfrom the sign-out trigger, and make the local repository'sreplacetolerant of a missing record. No interface or contract changes.Automated validation
Not run in this environment (no app/browser session). Covered by unit tests below.
Independent review
Self-reviewed the diff; the sentinel fallback, the sign-out trigger, and the throwing lookup were the three root causes and each is addressed at its source.
Test plan
bun test src/api src/auth/google/util src/events/repositories src/common/utils/sync(packages/web) — 79 pass, 0 fail, including new cases:handleErrorResponsedoes not sign out on a 404 data-endpoint response, and still does onUNAUTHORIZEDLocalEventRepository.replaceupserts (instead of throwing) when the target is absent from the store, and preserves an input-provided calendarCreated with PostHog Code from this inbox report.