Fall back to anonymous public reads when the GitHub proxy 401s - #79
Merged
Conversation
Signed-in users whose GitHub access can't be used by the Clerk proxy
(no connected GitHub account, or a token that can't reach the repo) got
a 401/403 from /api/github and the board came up empty — every issue
load failed with "GitHub authorization failed: 401" in the console.
Issue lists are public, so there's no reason a failed authenticated read
should leave the board blank. loadGitHubIssues now retries the read
anonymously against api.github.com when the proxy returns an auth error
(401/403 that isn't a genuine rate limit), so public issues still load.
The actionable "reconnect your GitHub access" message is now only shown
when even the anonymous fallback fails (e.g. a private repo).
buildGitHubRequest gains an { anonymous: true } option to force the
direct public path regardless of sign-in state, used to drive the retry.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NP24pkQzfsrcNsr12s99qa
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
Signed-in users whose GitHub access can't be used by the Clerk proxy — no connected GitHub account, or a token that can't reach the repo — got a
401/403from/api/githuband the board came up empty. Every issue load failed, spamming the console with:Issue lists are public, so a failed authenticated read has no reason to leave the board blank.
Fix
loadGitHubIssuesnow retries the read anonymously againstapi.github.comwhen the proxy returns an auth error (a401/403that isn't a genuine rate limit), so public issues still load even when the signed-in user's GitHub access can't be used by the proxy.buildGitHubRequestgains an{ anonymous: true }option to force the direct public GitHub path regardless of sign-in state; this drives the retry. Genuine rate limits (403withx-ratelimit-remaining: 0) are still detected and reported as rate limits, and are not retried.Testing
npm test— 975 passed.npm run test:coverage—github-api.jsandgithub-auth.jsremain at 100% statements/branches/functions/lines.401/403tests to assert the new fallback behavior and added a test for the "anonymous fallback also fails → surface auth error" path, plus abuildGitHubRequesttest for the{ anonymous: true }option.🤖 Generated with Claude Code
https://claude.ai/code/session_01NP24pkQzfsrcNsr12s99qa
Generated by Claude Code