fix: preserve OAuth query through consent - #255
Conversation
|
Warning Review limit reached
Next review available in: 55 minutes You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe change adds a shared OAuth query serializer. The consent and workspace selection pages use it for redirects and component props. Tests verify array handling and omission of undefined values. ChangesOAuth query serialization
Estimated code review effort: 1 (Trivial) | ~5 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 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 `@apps/web/src/app/oauth/oauth-query.test.ts`:
- Around line 5-8: Update the test around serializeOAuthQuery to use a two-value
scope array and assert that both scope entries appear in the serialized query,
while preserving the absent-value omission assertion.
In `@apps/web/src/app/oauth/select-workspace/page.tsx`:
- Line 16: Update the unauthenticated redirect in the OAuth workspace selection
page to include an encoded callbackURL pointing back to /oauth/select-workspace
with the serialized oauthQuery, matching the callback pattern used by the
consent page and preserving the signed request through sign-in.
🪄 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: 56ad7e15-871c-4afb-b0d2-675bb9ceea6f
📒 Files selected for processing (4)
apps/web/src/app/oauth/consent/page.tsxapps/web/src/app/oauth/oauth-query.test.tsapps/web/src/app/oauth/oauth-query.tsapps/web/src/app/oauth/select-workspace/page.tsx
| it("preserves the signed OAuth request while omitting absent values", () => { | ||
| expect( | ||
| serializeOAuthQuery({ client_id: "client", scope: ["lyrashield.read"], state: "state", absent: undefined }) | ||
| ).toBe("client_id=client&scope=lyrashield.read&state=state") |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Test repeated query values.
The array contains one value, so this test passes even when the serializer drops later values. Use a two-value array and assert that both serialized entries remain.
Proposed test update
- serializeOAuthQuery({ client_id: "client", scope: ["lyrashield.read"], state: "state", absent: undefined })
- ).toBe("client_id=client&scope=lyrashield.read&state=state")
+ serializeOAuthQuery({
+ client_id: "client",
+ scope: ["lyrashield.read", "lyrashield.write"],
+ state: "state",
+ absent: undefined,
+ })
+ ).toBe("client_id=client&scope=lyrashield.read&scope=lyrashield.write&state=state")📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| it("preserves the signed OAuth request while omitting absent values", () => { | |
| expect( | |
| serializeOAuthQuery({ client_id: "client", scope: ["lyrashield.read"], state: "state", absent: undefined }) | |
| ).toBe("client_id=client&scope=lyrashield.read&state=state") | |
| it("preserves the signed OAuth request while omitting absent values", () => { | |
| expect( | |
| serializeOAuthQuery({ | |
| client_id: "client", | |
| scope: ["lyrashield.read", "lyrashield.write"], | |
| state: "state", | |
| absent: undefined, | |
| }) | |
| ).toBe("client_id=client&scope=lyrashield.read&scope=lyrashield.write&state=state") |
🤖 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 `@apps/web/src/app/oauth/oauth-query.test.ts` around lines 5 - 8, Update the
test around serializeOAuthQuery to use a two-value scope array and assert that
both scope entries appear in the serialized query, while preserving the
absent-value omission assertion.
| }) { | ||
| const params = await searchParams | ||
| const session = await getSession() | ||
| const oauthQuery = serializeOAuthQuery(params) |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
Preserve the OAuth query for unauthenticated users.
When session is absent, Line 17 redirects to /sign-in without a callbackURL. The serialized query is discarded, so the user cannot return to /oauth/select-workspace with the signed request. Use the same encoded callback pattern as apps/web/src/app/oauth/consent/page.tsx.
Proposed fix
const oauthQuery = serializeOAuthQuery(params)
- if (!session) redirect("/sign-in")
+ if (!session)
+ redirect(`/sign-in?callbackURL=${encodeURIComponent(`/oauth/select-workspace?${oauthQuery}`)}`)📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| const oauthQuery = serializeOAuthQuery(params) | |
| const oauthQuery = serializeOAuthQuery(params) | |
| if (!session) | |
| redirect(`/sign-in?callbackURL=${encodeURIComponent(`/oauth/select-workspace?${oauthQuery}`)}`) |
🤖 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 `@apps/web/src/app/oauth/select-workspace/page.tsx` at line 16, Update the
unauthenticated redirect in the OAuth workspace selection page to include an
encoded callbackURL pointing back to /oauth/select-workspace with the serialized
oauthQuery, matching the callback pattern used by the consent page and
preserving the signed request through sign-in.
Passes the complete signed OAuth query from both workspace-selection and consent pages to Better Auth continuations. This prevents the provider from losing the authorization request during browser handoff.
Summary by CodeRabbit
Bug Fixes
Tests