Repository navigation
fix(errors): explain Platform API 403s caused by the workspace role - #621
Closed
seanperez29 wants to merge 1 commit into
Closed
seanperez29 wants to merge 1 commit into
seanperez29 wants to merge 1 commit into
Conversation
A workspace member whose dashboard role has no Platform API access (such as org:support or org:viewer) got "Failed to fetch application (403): Workspace role has no Platform API access", with no hint of what to do, and `clerk auth login` suggested `clerk apps create`, which fails the same way. The global error handler now explains the platform_oauth_access_token_role_has_no_access and authorization_missing_scopes 403s: it names the role, the roles that have access or the missing scope, and says to ask a workspace owner or admin or to switch workspaces and sign in again. A missing scope with CLERK_PLATFORM_API_KEY set blames the key instead. Agent and --json output keep the API's code and errors and add a docsUrl. Other 403s are unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: 279f03b The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
A Clerk Dashboard workspace member whose role has no Platform API access gets an unexplained 403 from every CLI command. Support, Viewer and Guest are roles any customer can give a teammate (
clerk_goapi/dapi/constants/rbac.go). For example:Two more problems in the same situation:
clerk auth loginsuggestsclerk apps create, which fails the same way.Missing authorization scopes, without the scope's name.The backend already explains both cases:
platform_oauth_access_token_role_has_no_access, withmeta.roleandmeta.roles_with_access. Defined inapi/apierror/platform.go, raised inplatformauth/oat_strategy.go.authorization_missing_scopes, withmeta.scopes. Defined inapi/apierror/auth.go.The CLI printed only the short message.
Change
The global error handler now explains Platform API 403s that carry either of those two codes:
clerk auth logoutandclerk auth login. Logging out comes first because, in agent mode,clerk auth loginreturns early when a session exists.CLERK_PLATFORM_API_KEYinstead.CLERK_PLATFORM_API_KEYis set, it says the key lacks the scope, not the role.--json: the error keeps the API'scodeanderrorsunchanged and adds adocsUrlfor managing team access.clerk auth login's default-application warning uses the same explanation.Every other 403, Backend API or Frontend API error, and other error code prints as before.
Before:
After:
Verification
errors.test.ts,cli-program.test.tsandfirst-application.test.ts:meta;bun run format,lint,typecheck,testandformat:checkall pass.clerk apps listandclerk link --appagainst a local server returning the real 403 body, in human and agent mode.Not changed here
lib/autoclaim.ts).isAuthError()treats every 403 as a sign-in problem, somigrate exportreports this role error as not being signed in.Both are worth fixing on their own.
🤖 Generated with Claude Code