Skip to content

refactor(core): own the oauth callback emptiness rule in one place - #5288

Merged
tyler-dane merged 2 commits into
mainfrom
claude/kind-dirac-q8zghz
Nov 18, 2026
Merged

tyler-dane merged 2 commits into
mainfrom
claude/kind-dirac-q8zghz

Conversation

@tyler-dane

Copy link
Copy Markdown
Contributor

The divergence this prevents

#5282 added isOAuthCallbackQueryEmpty to packages/core/src/analytics/oauth-signup.events.ts so the backend callback service could ignore crawler GETs carrying no state, code, or error. In the same PR, the web landing recorder re-implemented the inverse rule locally as oauthCallbackSearchHasParams, in a file that already imports from that very module.

The two copies disagreed on whitespace:

rule ?state=%20
isOAuthCallbackQueryEmpty (core, owner) value.length > 0 not empty
oauthCallbackSearchHasParams (web copy) value.trim() empty

So a callback like ?state=%20 was junk to the web gate (relay skipped) and a real callback to the backend gate, which fell through to oauthFailedReasonFromCallbackQuery and captured an oauth_callback failure with reason missing_code. That is exactly the false failure #5282 set out to remove, still reachable through the other door. No test covered the whitespace case on either side, so the two could keep drifting silently.

The change

  • The web recorder parses the query and calls core's rule instead of its own copy, so emptiness is defined once.
  • The rule trims, so a blank param is ignored the same way a bare one is. This completes fix(auth): stop false oauth_callback failures from empty OAuth callbacks #5282's stated intent ("ignore crawler GETs with no state, code, or error") rather than introducing a new policy.
  • Regression tests pin the whitespace case at all three sites: the core rule, the web relay gate, and the backend service's redirect-home path.

Behavior delta, stated plainly: the only observable change is for whitespace-only callback params, which now redirect home without a PostHog capture instead of recording a missing_code failure. No user-visible behavior and no contract change.

The provider === "apple" early return stays local to the web file on purpose: it is a fact about Apple's response_mode (the form POST already recorded the callback), not about whether the query carries anything. Only the emptiness half moved.

Examined and deliberately left alone

Recorded in .agents/skills/tech-debt-sweep/judged-fine.md so the next sweep does not redo it: #5283's 6,058-line Mac removal (no orphaned branches; the legacy d: true OAuth-state tolerance is deliberate), BillingCheckoutRequestSchema going .strict() (nothing live can send a property to reject), DESKTOP_QUICK_ADD_PALETTE_PLACEHOLDER (live web palette feature, renaming is inadmissible), #5286's ring-color fix (finished work), and asNonEmptyString in oauth-callback.analytics.ts (narrows four unknown values and agrees with core rather than diverging).

Verify

bun run verify --strict: lint, type-check, knip, test:web, test:a11y and test:e2e all pass.

VERDICT: FAIL

The verdict is driven entirely by pre-existing sandbox failures, confirmed by running both suites at origin/main (70c4082) in this same container:

PRE-EXISTING (identical at origin/main, unrelated to this diff):

  • test:core 1 failure: configureHttpServer > does not reject a request that exceeds maxHeadersCount
  • test:backend:fast 13 failures: 3x GET /api/config, 10x SSE Server (both need compass.yaml, absent in this sandbox)

Counts confirm this branch only adds passing tests: core 1084 pass vs 1083 on main, backend 686 pass vs 685 on main, with the same 14 failures on both sides.

FLAKY, passed on rerun (1):

  • test:e2e: [chromium-desktop] › e2e/timed/event-form-fast-typing.spec.ts › title keeps every character when typed quickly in day view

CI decides on the suites this sandbox cannot configure.


Generated by Claude Code

#5282 added `isOAuthCallbackQueryEmpty` to core so the backend callback
service could ignore crawler GETs that carry no state, code, or error, then
re-implemented the inverse rule in the web landing recorder as
`oauthCallbackSearchHasParams`. The two copies disagreed: core tested
`value.length > 0`, the web copy tested `value.trim()`.

So a callback like `?state=%20` was junk to the web gate (relay skipped) and
a real callback to the backend gate, which captured an `oauth_callback`
failure with reason `missing_code` - the false failure #5282 set out to
remove, still reachable through the other door. No test covered the
whitespace case on either side.

The web recorder now parses the query and calls core's rule, and the rule
trims, so both doors agree and blank params are ignored like bare ones. The
`provider === "apple"` skip stays local: it is a fact about Apple's
`response_mode`, not about whether the query carries anything.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HmwVQHPX46EeQkypGBcMuw
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HmwVQHPX46EeQkypGBcMuw
@tyler-dane
tyler-dane enabled auto-merge November 18, 2026 11:47
@github-actions

Copy link
Copy Markdown
Contributor

Boot bundle: 576.4 KB gzip (+0.0 KB vs main)

@tyler-dane
tyler-dane added this pull request to the merge queue Nov 18, 2026
Merged via the queue into main with commit c5131d9 Nov 18, 2026
23 checks passed
@tyler-dane
tyler-dane deleted the claude/kind-dirac-q8zghz branch November 18, 2026 12:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants