Skip to content

fix(rate-limits): stop treating Cursor HTTP 403 as expired sign-in - #23626

Closed
Li-Sanze wants to merge 2 commits into
stablyai:mainfrom
Li-Sanze:fix/cursor-usage-error-classification
Closed

Li-Sanze wants to merge 2 commits into
stablyai:mainfrom
Li-Sanze:fix/cursor-usage-error-classification

Conversation

@Li-Sanze

@Li-Sanze Li-Sanze commented Sep 28, 2026 •

Copy link
Copy Markdown

ELI5

When Cursor refuses a usage request with HTTP 403, Orca should show the request failure instead of telling a signed-in user to log in again.

What Changed

Only HTTP 401 and the existing local token-expiry check report expired sign-in. Other non-OK responses reuse the existing HTTP-status error. Both usage endpoints share this behavior; redirect cancellation remains a generic network failure.

Why

403 does not establish expired credentials. This changes one condition, corrects its nearby comment, and adds regression coverage; no new login-path assumptions or transport changes.

Linked Issue

Refs #23612 (error classification only). The original failing response was not captured; this does not establish its root cause or fix network connectivity. The separate Codex proxy work remains tracked in #19931 and #11862.

Visual Proof

N/A — main-process classification only; no layout or interaction code changed. Existing error rendering is reused:

Response Before After
HTTP 403 / 304 Sign-in expired; log in again Refresh failed; HTTP status retained
HTTP 401 / expired token Sign-in expired Unchanged

Testing

  • I manually tested these changes locally
  • Automated tests added/updated

macOS arm64: 59 Cursor tests pass; full lint and typecheck pass.
pnpm test --maxWorkers=2 was stopped (exit 130) after cross-version fixture failures; a focused rerun confirmed the required release tag v1.4.190 is absent locally. This is not a passing full-suite run. GitHub PR Checks currently require maintainer approval before they can run.
Build: desktop, CLI and web bundles pass; pnpm build stops at the mobile web bundle because this checkout lacks mobile dependencies (react-native-web, expo-router). Full application UI, Windows/Linux and SSH runtime checks were not performed.

A windowless Electron 43.7.0 loopback fixture confirmed 401/403/304 return responses; 302/307 reject with Redirect was cancelled and do not follow the target. No account credentials were used.

AI Disclosure

Implemented/reviewed with Codex (GPT-6); independently cross-reviewed with Cursor Agent (Grok 4.7).

Review

Cursor's final review found no blockers. Pullfrog and CodeRabbit reviewed cc2164e5 with no actionable code findings; CodeRabbit's generic docstring-coverage warning does not warrant expanding this fix. Cross-platform/SSH/local: shared main-process logic, no paths or host assumptions added. Agents/integrations: Cursor-only; no wire-format changes. Performance/security: no added requests, logging or credential handling; redirects remain manual. UI: existing error display reused.

Agent skill upstream boundary

  • Not applicable; no upstream skill material copied.

Author

GitHub: @Li-Sanze · X: @evidentloop

Notes

No release, proxy, authentication-storage or mobile protocol changes.

Checklist

  • Small, focused change with explanation and regression tests
  • Visual-proof scope explained above
  • Reviewed correctness, security, performance and platform/SSH compatibility
  • All four full gates pass locally (build limitation above; CI required)

Keep expired-sign-in reporting for HTTP 401 and redirects to Cursor's
login page. Preserve the HTTP status for forbidden responses and other
redirects instead of asking users to sign in again.

Cover both usage endpoints and relative, foreign, or malformed redirect
locations with regression tests.

Refs stablyai#23612
Remove the login redirect predicate: Electron net.fetch rejects manual
redirects before a Response reaches the classifier. Keep the existing
local token-expiry check and preserve HTTP errors through the existing
fallback instead of guessing a login URL.

Cover forbidden responses on both endpoints, HTTP 304, redirect
cancellation, and preservation of manual redirect mode.

Refs stablyai#23612
@coderabbitai

coderabbitai Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 50c1a07c-f2c7-4171-8ab5-34e0ce46a3d8

📥 Commits

Reviewing files that changed from the base of the PR and between aedb930 and cc2164e.

📒 Files selected for processing (2)
  • src/main/rate-limits/cursor-fetcher.test.ts
  • src/main/rate-limits/cursor-fetcher.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

fetchDashboardJson now treats only HTTP 401 responses as expired credentials. HTTP 403 and 3xx responses follow general HTTP failure handling. Tests cover manual redirects, HTTP failures from the legacy usage endpoint, and generic errors for DNS failures and cancelled redirects.

Priority: ⬇️ Low

Merge Risk: ⚪ Minimal · up to cc216

No actionable issue remains in the supplied change; merge after normal CI validation.

Architecture Summary

Architecture risk: 🔵 Low · up to cc216

The change affects 1 system.

Changed systems: src

Architecture concerns
No architecture-level concerns identified.

Review details

Systems and components

  • observed — src (service) was modified; 2 changed files map to changed impact.

Before / after behavior

  • observed — Modified behavior in src/main/rate-limits/cursor-fetcher.test.ts: Added an assertion that the usage request sets redirect to manual.
  • observed — Modified behavior in src/main/rate-limits/cursor-fetcher.test.ts: Replaced the test that classified a redirect to /login as an expired session with cases for HTTP 403 and 304. Both are expected to return an HTTP-specific error with server failure metadata and auth provenance.
  • observed — Modified behavior in src/main/rate-limits/cursor-fetcher.test.ts: Added a test that a 403 response from the legacy usage endpoint returns its HTTP-specific error and is classified as a server failure.
  • observed — Modified behavior in src/main/rate-limits/cursor-fetcher.test.ts: Expanded the network-failure test to cover both DNS lookup failure and a cancelled redirect; each expects a generic error and network failure classification.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
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.
Title check ✅ Passed The title clearly identifies the primary change: HTTP 403 responses are no longer treated as expired sign-in errors in Cursor rate-limit handling.
Description check ✅ Passed The description includes all required sections, explains the user-facing behavior and implementation, links issue #23612, documents testing limitations, and records review and checklist status. It cle…
  • Fix all pre-merge checks with AI

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.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ No new issues found.

Reviewed changes

This run reviewed both commits on the branch — the Cursor usage error-classification fix in cursor-fetcher.ts and its regression tests.

  • Expiry classification narrowed to HTTP 401 — the base predicate (401 || 403 || 3xx → stale-token) is now 401 only; 403, 304 and other non-OK responses fall through to the existing !res.ok bucket with failureKind: 'server' and the HTTP status retained, while authProvenance is still published so the account-switch guard keeps working. The local token-expiry precheck is unchanged.
  • Login-redirect predicate removed — commit 1's isCursorLoginRedirect() helper (and the 3xx branch it replaced) is gone. Verified against Electron 43.7.0 source that net.fetch resolves redirect: 'manual' through fetchWithSession, which passes the mode to ClientRequest with no redirect handler, so an unfollowed redirect rejects before any Response reaches the classifier. The removed branches were dead code; real redirects already surfaced as failureKind: 'network', so this is not a UX regression.
  • Redirect comment rewritten — redirect: 'manual' stays, now documented as a security choice (do not follow dashboard redirects with session credentials).
  • Tests updated — 403/304 and the legacy-endpoint 403 now assert the HTTP status text and server kind; the removed 302 → stale-token case is replaced by a rejection case for Redirect was cancelled. The 403/304 assertions fail against the base predicate, so they are real regression coverage. cursor-fetcher.test.ts: 18 passed locally.

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@nwparker

nwparker commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

Superseded by merged #24575. Thank you @Li-Sanze for the Cursor HTTP-status classification fix; credit is preserved in the successor. Both usage endpoints distinguish request failures from expired credentials. The original failing authenticated request remains tracked in #23612; this closure retires the duplicate implementation, not that unresolved report.

@nwparker nwparker closed this Oct 2, 2026
nwparker added a commit that referenced this pull request Oct 4, 2026
Keep Cursor quota requests tied to the selected account by omitting ambient Electron session credentials. Preserve explicit account cookies and redirect handling.

Credit: Li-Sanze for the original credential-mode fix in #23626, carried through #24575; jjongsta and chengjiaxiao for the reports. Native HTTP/HTTPS cookie isolation, mutation controls and proxy behavior were verified before merging. This does not claim to resolve the separate initial-authentication failure in #23612.
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