fix: handle expired OAuth token on git push/pull (issue #14) - #32
Conversation
- Detect auth failures in push/pull routes and return TOKEN_EXPIRED code - Show notification with link to /hub/home for server restart - Update git remote URL with fresh token on each server spawn - Push new user branch to remote during init - Add Gitea token expiry config for local reproduction Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Preview environment failed to start. |
|
Warning Review limit reached
More reviews will be available in 9 minutes and 11 seconds. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?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 credits. 🚦 How do rate 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 see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThe PR shortens Gitea OAuth token lifetime, updates the singleuser GitLab init flow, returns ChangesGitLab OAuth token expiry handling
Sequence Diagram(s)sequenceDiagram
participant User
participant GitPanel
participant GitRoute as server/routes/git.js
participant AntdNotification as antd.notification
User->>GitPanel: click Push or Pull
GitPanel->>GitRoute: POST /push or POST /pull
GitRoute-->>GitPanel: 401 { code: TOKEN_EXPIRED }
GitPanel->>AntdNotification: showTokenExpired()
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 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: 4
🤖 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 `@k8s/jupyterhub-values.yaml`:
- Around line 115-120: The existing-workspace early-exit path in the JupyterHub
startup script only refreshes the remote URL and skips the new branch backfill
logic. Update this branch of the initialization flow so that, after resetting
the origin in the existing workspace path, it also ensures the user branch is
present on the remote by performing the same push/backfill behavior as the
normal initialization path, using the same branch and repo variables already
referenced there.
In `@server/routes/git.js`:
- Around line 98-100: The auth error response in git routes is leaking raw git
stderr via err.message, which can include the embedded remote URL and token.
Update the isAuthError branch in the git route handler to return a generic 401
message while preserving the stable TOKEN_EXPIRED code, and apply the same
change in the matching auth-error response path referenced by the other
occurrence.
- Around line 226-229: The isAuthError helper in git route handling is too broad
because it treats every 403 as an authentication expiration, which can mislabel
normal permission failures. Update isAuthError to keep the existing auth-related
message checks and 401 handling, but remove the generic 403 match so the push
route’s denied/permission branch can handle those cases correctly.
In `@src/components/GitPanel.jsx`:
- Around line 50-64: The persistent token-expired notice in showTokenExpired is
stacking because each call creates a new Ant Design notification with duration:
0. Update the notification.error call to use a stable key so repeated push/pull
failures reuse the same “Session Expired” notification instead of adding
duplicates. Locate the change in GitPanel and keep the existing
message/description behavior intact.
🪄 Autofix (Beta)
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: 26086c78-9d98-4cfe-9b3d-3eceb64678d5
📒 Files selected for processing (4)
k8s/gitea-values.yamlk8s/jupyterhub-values.yamlserver/routes/git.jssrc/components/GitPanel.jsx
- Sanitize TOKEN_EXPIRED error message to avoid leaking git remote URL with token - Remove 403 from isAuthError to avoid mislabeling permission failures - Add stable key to token-expired notification to prevent stacking - Ensure remote branch is pushed when missing in existing workspace path Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Summary
Authentication failederrors in push/pull routes and return{ code: 'TOKEN_EXPIRED' }with HTTP 401/hub/hometo restart the JupyterHub server.git/config)Reproduction (local)
k8s/gitea-values.yamlsetsACCESS_TOKEN_EXPIRATION_TIME: 300to simulate token expiry locally with Gitea instead of GitLab.Test plan
Closes #14
🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Bug Fixes