Skip to content

fix(sdk): scope PAT detail to active org and show a unified not-found page - #1895

Open
rohilsurana wants to merge 2 commits into
mainfrom
fix/pat-detail-org-scope-not-found
Open

fix(sdk): scope PAT detail to active org and show a unified not-found page#1895
rohilsurana wants to merge 2 commits into
mainfrom
fix/pat-detail-org-scope-not-found

Conversation

@rohilsurana

@rohilsurana rohilsurana commented Aug 19, 2026

Copy link
Copy Markdown
Member

Problem

The current-user PAT management flows (get, update, delete, regenerate) scope the token lookup by the logged-in user, not by the org. A user who belongs to more than one org could open, edit, regenerate, or delete a token that belongs to another org just by changing the org in the URL. The token also rendered under any org the user is a member of.

The PAT detail view is where all of this happens. It fetches the token by id and hosts the Update, Regenerate, and Revoke actions.

Fix

A client-side guard in the PAT detail view. The PAT response already carries its org_id, so we compare it with the active org from the route.

  • If the token belongs to a different org, or the id is unknown or malformed (NotFound / InvalidArgument), show a generic "Token not found" state with no actions. The same message covers all of these, so it reveals nothing about tokens in other orgs.
  • Any other failure (network, server error, and so on) shows a separate "Something went wrong" state with a Try again button. We do not claim the token is missing when the real problem is transient.

Retry is tuned to match. A NotFound or invalid id is a definite answer and is not retried, so the not-found state shows right away. Other failures may be transient, so they are retried a couple of times before the error state appears. Before this, the query used the default retry of 3, which retried even a 404 three times.

No proto or server change is needed. The list view already scopes its search by org.

Testing

Ran a local sandbox with one user in two orgs, each with a PAT, and checked:

  • Token opened in its own org: details render as before.
  • Token opened under a different org: "Token not found", no actions.
  • Unknown or malformed token id: same "Token not found", shown right away with no retries.
  • Server made unreachable: "Something went wrong" with a Try again button, and Try again recovers once the server is back.

Notes

This is a UI guard. A direct RPC call is still not org-scoped on the server, which is a separate, deeper change.

@vercel

vercel Bot commented Aug 19, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
frontier Ready Ready Preview Aug 19, 2026 8:26am

@coderabbitai

coderabbitai Bot commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 8d9dd1b4-64d9-44f6-8251-8795e266b429

📥 Commits

Reviewing files that changed from the base of the PR and between 1e7727e and a961c2b.

📒 Files selected for processing (1)
  • web/sdk/client/views/pat/pat-details-view.tsx

Included review availability: Your plan provides up to 2 included reviews per hour; 1 remains after this review.


📝 Walkthrough

Summary by CodeRabbit

  • Bug Fixes

    • Improved personal access token loading by retrying temporary failures automatically.
    • Invalid or unavailable tokens now display clear, dedicated messages instead of generic notifications.
    • Added clearer handling for connection errors and unexpected failures.
  • Usability Improvements

    • Added actions to retry loading or navigate away when token details cannot be displayed.
    • Improved visual guidance for missing, inaccessible, or invalid tokens.

Walkthrough

The PAT detail view now classifies loading errors, retries transient failures up to twice, and renders dedicated states for invalid, missing, mismatched, and unexpected failures.

Changes

PAT detail error handling

Layer / File(s) Summary
Retry classification and dependencies
web/sdk/client/views/pat/pat-details-view.tsx
The PAT detail query does not retry NotFound or InvalidArgument errors. Other failures retry up to two times. Toast-based error handling was removed.
Explicit PAT error states
web/sdk/client/views/pat/pat-details-view.tsx
Invalid, missing, and organization-mismatched tokens render a not-found state. Unexpected failures render an empty state with a retry action and breadcrumb navigation.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Merge Risk: ⚪ Minimal · up to a961c

This localized change scopes PAT detail handling to the active organization and separates not-found responses from transient errors; no actionable merge-blocking risk remains beyond normal checks and review.

Suggested reviewers: rohanchkrabrty

🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 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.

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.

@coveralls

coveralls commented Aug 19, 2026

Copy link
Copy Markdown

Coverage Report for CI Build 32232541493

Coverage remained the same at 48.739%

Details

  • Coverage remained the same as the base build.
  • Patch coverage: No coverable lines changed in this PR.
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 40091
Covered Lines: 19540
Line Coverage: 48.74%
Coverage Strength: 15.66 hits per line

💛 - Coveralls

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