Skip to content

Redirect bare /connect/oauth visits to the OAuth guide - #1352

Merged
kody-bot merged 1 commit into
mainfrom
cursor/connect-oauth-bare-redirect-c0a2
Aug 10, 2026
Merged

kody-bot merged 1 commit into
mainfrom
cursor/connect-oauth-bare-redirect-c0a2

Conversation

@kentcdodds

@kentcdodds kentcdodds commented Aug 10, 2026 •

Copy link
Copy Markdown
Owner

What

/connect/oauth with no meaningful query parameters now 302s to /guides/oauth instead of rendering the blank config form.

Why

Every working visit to the page carries at least one of three parameters: provider (agent-built setup URLs and built-in connects), code (the provider's success redirect β€” the redirect URI strips the config query, which sessionStorage restores client-side), or error (the provider's denial redirect, e.g. access_denied). A visit with none of them has no flow to set up or resume β€” someone typed the URL or followed a bare link β€” and the blank form assumes an agent is driving. The guide explains how to actually use the page.

How

  • isBareConnectOauthVisit in the server handler, checked before the session gate (the guide is public, so anonymous bare visitors skip the login bounce).
  • The client route mirrors the check for SPA-internal navigations.
  • Handler tests cover all three param shapes plus the bare redirect and the still-gated provider visit.

Testing

npm run validate green. Live smoke test on the dev server: bare visit β†’ 302 /guides/oauth; ?provider=github (anonymous) β†’ 302 to login as before.

Open in WebΒ Open in CursorΒ 

Summary by CodeRabbit

  • New Features

    • Added guidance for visitors who open the OAuth connection page without required connection details, redirecting them to the OAuth guide.
    • Preserved existing handling for valid OAuth callbacks and configured connection flows.
    • Anonymous visits with a provider specified continue through the login flow.
  • Bug Fixes

    • Prevented incomplete OAuth visits from reaching the standard connection flow.

Every working visit carries provider (agent-built setup URLs and
built-in connects), code (the provider's success redirect; config is
restored from sessionStorage), or error (the provider's denial
redirect). A visit with none of them has no flow to set up or resume,
so send it to /guides/oauth instead of rendering the blank config
form. The server handler checks before the session gate (the guide is
public) and the client route mirrors the check for SPA-internal
navigations. Covered by handler tests for all three param shapes.

Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
@coderabbitai

coderabbitai Bot commented Aug 10, 2026 •

Copy link
Copy Markdown

Review Change Stack

πŸ“ Walkthrough

Walkthrough

Bare /connect/oauth visits now redirect to /guides/oauth before authentication. OAuth callback, denial, provider, and configured-flow handling remain unchanged. The client route applies the same redirect for browser visits.

Changes

OAuth guide redirect

Layer / File(s) Summary
Server-side bare visit redirect
packages/worker/src/app/handlers/connect-oauth.ts, packages/worker/src/app/handlers/connect-oauth.node.test.ts
The handler detects URLs without provider, code, or error parameters and returns a 302 redirect to /guides/oauth before the session gate. Tests cover bare, state-only, callback, denial, and anonymous provider visits.
Client-side route guard
packages/worker/client/routes/connect-oauth.tsx
The client route redirects browser visits without provider or callback parameters to /guides/oauth.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

πŸš₯ Pre-merge checks | βœ… 5
βœ… Passed checks (5 passed)
Check name Status Explanation
Title check βœ… Passed The title clearly and concisely describes the main change: redirecting bare OAuth visits to the OAuth guide.
Description check βœ… Passed The description explains the intent, changes, flow behavior, and testing; the optional system changes section is not required.
Docstring Coverage βœ… Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check βœ… Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check βœ… Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
πŸ“ Generate docstrings
  • Create stacked PR
  • Commit on current branch
πŸ§ͺ Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch cursor/connect-oauth-bare-redirect-c0a2

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❀️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown
Contributor

πŸ”Ž Preview deployed: https://kody-pr-1352.kody-a99.workers.dev

Worker: kody-pr-1352
D1: kody-pr-1352-db
KV: kody-pr-1352-oauth-kv

Mocks:

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

πŸ€– Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/worker/src/app/handlers/connect-oauth.ts`:
- Around line 15-18: Replace value-based get() checks with URLSearchParams.has()
in isBareConnectOauthVisit and the matching client-side OAuth classification at
packages/worker/client/routes/connect-oauth.tsx:96-105, so empty-but-present
provider, code, and error parameters are recognized as OAuth flows. Add coverage
in packages/worker/src/app/handlers/connect-oauth.node.test.ts:19-33 for each
empty-but-present parameter case.
πŸͺ„ Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
βš™οΈ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: f71fd27d-f9c6-420e-af2b-92287697fc1c

πŸ“₯ Commits

Reviewing files that changed from the base of the PR and between 4911014 and 57caee6.

πŸ“’ Files selected for processing (3)
  • packages/worker/client/routes/connect-oauth.tsx
  • packages/worker/src/app/handlers/connect-oauth.node.test.ts
  • packages/worker/src/app/handlers/connect-oauth.ts

Comment on lines +15 to +18
export function isBareConnectOauthVisit(url: URL): boolean {
const params = url.searchParams
return !params.get('provider') && !params.get('code') && !params.get('error')
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟑 Minor | ⚑ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf 'Files:\n'
git ls-files | rg '(^|/)connect-oauth(\.ts|\.tsx|\.node\.test\.ts)$|connect-oauth' || true

printf '\nRelevant snippets:\n'
for f in \
  packages/worker/src/app/handlers/connect-oauth.ts \
  packages/worker/client/routes/connect-oauth.tsx \
  packages/worker/src/app/handlers/connect-oauth.node.test.ts
do
  if [ -f "$f" ]; then
    echo "--- $f"
    nl -ba "$f" | sed -n '1,140p'
  fi
done

printf '\nSearch for isBareConnectOauthVisit/tests:\n'
rg -n "isBareConnectOauthVisit|bareConnectOauth|has\\(['\"](provider|code|error)\\)|get\\(['\"](provider|code|error)\\)" packages/worker || true

printf '\nURLSearchParams behavior probe:\n'
node - <<'JS'
for (const value of ["provider", "code", "error"]) {
  const params = new URLSearchParams(`${value}=`)
  console.log(`${value}=: get='${params.get(value)}' has=${params.has(value)} !get=${!!params.get(value)}`)
}
console.log('empty: get=', new URLSearchParams('provider=code=error=').get('provider'), ', has=', new URLSearchParams('provider=code=error=').has('provider'))
JS

Repository: kentcdodds/kody

Length of output: 658


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf 'Relevant snippets:\n'
for f in \
  packages/worker/src/app/handlers/connect-oauth.ts \
  packages/worker/client/routes/connect-oauth.tsx \
  packages/worker/src/app/handlers/connect-oauth.node.test.ts
do
  if [ -f "$f" ]; then
    echo "--- $f"
    awk '{printf "%6d\t%s\n", NR, $0}' "$f" | sed -n '1,140p'
  fi
done

printf '\nSearch for isBareConnectOauthVisit/tests:\n'
rg -n "isBareConnectOauthVisit|bareConnectOauth|has\\(['\"](provider|code|error)\\)|get\\(['\"](provider|code|error)\\)" packages/worker || true

printf '\nURLSearchParams behavior probe:\n'
node - <<'JS'
for (const value of ["provider", "code", "error"]) {
  const params = new URLSearchParams(`${value}=`)
  console.log(`${value}=: get='${params.get(value)}' has=${params.has(value)} !get=${!!params.get(value)}`)
}
console.log('empty: get=', new URLSearchParams('provider=code=error=').get('provider'), ', has=', new URLSearchParams('provider=code=error=').has('provider'))
JS

Repository: kentcdodds/kody

Length of output: 9284


Use URLSearchParams.has() for OAuth flow classification.

get() returns '' for a present empty parameter, so ?provider=, ?code=, and ?error= are treated as bare visits and redirect to /guides/oauth. This contradicts the comments that describe visits containing provider, code, or error as OAuth flows.

Update the server-side check at packages/worker/src/app/handlers/connect-oauth.ts#L15-L18, the matching client-side check at packages/worker/client/routes/connect-oauth.tsx#L96-L105, and add coverage for the empty-but-present parameter cases.

Proposed fix
- return !params.get('provider') && !params.get('code') && !params.get('error')
+ return !params.has('provider') && !params.has('code') && !params.has('error')
πŸ“ Affects 3 files
  • packages/worker/src/app/handlers/connect-oauth.ts#L15-L18 (this comment)
  • packages/worker/client/routes/connect-oauth.tsx#L96-L105
  • packages/worker/src/app/handlers/connect-oauth.node.test.ts#L19-L33
πŸ€– Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/worker/src/app/handlers/connect-oauth.ts` around lines 15 - 18,
Replace value-based get() checks with URLSearchParams.has() in
isBareConnectOauthVisit and the matching client-side OAuth classification at
packages/worker/client/routes/connect-oauth.tsx:96-105, so empty-but-present
provider, code, and error parameters are recognized as OAuth flows. Add coverage
in packages/worker/src/app/handlers/connect-oauth.node.test.ts:19-33 for each
empty-but-present parameter case.

@kody-bot
kody-bot merged commit 61ac6ba into main Aug 10, 2026
10 checks passed
@kody-bot
kody-bot deleted the cursor/connect-oauth-bare-redirect-c0a2 branch August 10, 2026 00:49
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.

3 participants