Repository navigation
fix(docs): accept a GitHub token for docs content reads - #48364
Conversation
App-only GitHub auth blocks contributors without the docs App private key in two places: 1. The search index. The lint warnings source throws, and because every source shares one Promise.all in fetchAllSources, the whole embeddings run aborts before doing any work. 2. The build. prebuild -> fetch-federated-content -> lib/octokit.ts throws 'DOCS_GITHUB_APP_PRIVATE_KEY environment variable is required', so the `npm run build` pre-flight CONTRIBUTING.md asks for cannot run either. Add one rung below the App: a token from GH_TOKEN, then GITHUB_TOKEN, matching the precedence the GitHub CLI documents (gh help environment) so an already-exported token just works. Any token Octokit accepts is fine here, so a gh OAuth token or an Actions installation token both work. Both rungs are authenticated, so the 60 req/hr per IP limit behind the flaky CI failures in #43015 stays fixed, and GitHub content still goes through an authenticated Octokit client per #44274. Production and CI keep using the App. A partially configured App is an error, not a fall-back: if some but not all DOCS_GITHUB_APP_* vars are set, throw naming the missing ones. Otherwise a rotated-out or misnamed secret could be masked by whatever token happens to be in the environment, quietly reading as the wrong identity. This also tightens lib/octokit.ts, which previously passed appId and installationId through without checking them. The helper lives in lib/octokit.auth.ts, free of server-only imports so both Next and the search scripts can use it. That removes two of the three copies of this construction; github-discussion.ts still has its own, left alone because it has no callers, so a change there cannot be exercised. githubAuthOptions() returns Octokit options rather than a client, so the choice is plain data: callers construct the client, and the tests assert the real auth values (including the PKCS1 -> PKCS8 conversion the App path depends on) without instantiating anything or reaching the network. The two token vars are declared in apps/docs/turbo.jsonc alongside the existing DOCS_GITHUB_APP_* entries, which turbo/no-undeclared-env-vars requires.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
This pull request has been ignored for the connected project Preview Branches by Supabase. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (5)
🚧 Files skipped from review as they are similar to previous changes (5)
📝 WalkthroughWalkthroughChangesThe PR centralizes GitHub authentication in GitHub authentication flow
Estimated code review effort: 3 (Moderate) | ~20 minutes Mergeability Score: ⚪ Minimal · up to This change adds a documented GitHub token fallback for local docs content reads while preserving existing App authentication behavior. No actionable merge-blocking risk remains based on the supplied evidence. Sequence Diagram(s)sequenceDiagram
participant DocsClient
participant githubAuthOptions
participant RetryOctokit
participant GitHubAPI
DocsClient->>githubAuthOptions: request authentication options
githubAuthOptions-->>DocsClient: return App or token auth
DocsClient->>RetryOctokit: construct authenticated client
RetryOctokit->>GitHubAPI: fetch repository content
GitHubAPI-->>RetryOctokit: return content
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 Biome (2.5.6)apps/docs/turbo.jsoncFile contains syntax errors that prevent linting: Line 8: Expected a property but instead found '}'.; Line 12: Expected a property but instead found '}'.; Line 18: Expected a property but instead found '}'.; Line 22: Expected a property but instead found '}'.; Line 76: Expected an array, an object, or a literal but instead found ']'.; Line 79: Expected a property but instead found '}'.; Line 80: Expected a property but instead found '}'.; Line 81: Expected a property but instead found '}'. 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 |
The block described the auth ladder as a proposal; it is now an open PR. Replaces
the design discussion with the actual requirement (a --docs checkout containing
#48364, or that branch checked out until it merges) and records what the
end-to-end run showed: the seed completes, and a tools-mode eval's search_docs
returns content that exists only in the local index.
Keeps the two upstream rough edges visible rather than implying the seed is
healthy: it exits 0 while silently failing 22 /reference/{javascript,dart} pages
whose sections exceed the 8192-token embedding limit, and a local index has no
partner-integration pages because that source reads the hosted misc project.
Also drops 'PAT': the rung accepts any token Octokit takes, including a gh OAuth
token or an Actions installation token.
|
Approach looks sound. I hit a snag testing this locally, but found a resolution. The issue was that I have secrets pulled into In my testing, these took precedent and failed the Anyway, I got it working by overriding those export DOCS_GITHUB_APP_ID='' DOCS_GITHUB_APP_INSTALLATION_ID='' DOCS_GITHUB_APP_PRIVATE_KEY=''
export GH_TOKEN=$(gh auth token)
pnpm turbo run build --filter=docs --forceOr for a more targeted test, running |
…-github-pat-fallback
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
Braintrust eval report
|
README gets a "Local development loop" section covering the three agent inputs and how to override each: edit the skills tree and just run, build the mcp repo anywhere and pass --mcp, serve docs from your own supabase/supabase checkout and pass --content-api. It states where the keys go, and that `compare` is a screen rather than causal proof. It also records the one live limitation: `docs seed` needs a docs checkout carrying supabase/supabase#48364, which is still open. Without it fetchAllSources unconditionally awaits the lint-warnings source, whose loader needs the docs GitHub App, and a shared Promise.all turns that into a full abort before any embedding, so a failed attempt costs nothing. Two upstream rough edges are named rather than glossed: the seed exits 0 while silently failing 22 reference pages whose sections exceed the 8192-token embedding limit, and a local index has no partner-integration pages because that source reads the hosted misc project. AGENTS.md is the agent-facing version: which loop to run for a given kind of change, the spend rules for anything that costs money, and the same limitations stated as operational guidance. CLAUDE.md points at it. Verified: smoke 27/27, tsc and biome clean.
README gets a "Local development loop" section covering the three agent inputs and how to override each: edit the skills tree and just run, build the mcp repo anywhere and pass --mcp, serve docs from your own supabase/supabase checkout and pass --content-api. It states where the keys go, and that `compare` is a screen rather than causal proof. It also records the one live limitation: `docs seed` needs a docs checkout carrying supabase/supabase#48364, which is still open. Without it fetchAllSources unconditionally awaits the lint-warnings source, whose loader needs the docs GitHub App, and a shared Promise.all turns that into a full abort before any embedding, so a failed attempt costs nothing. Two upstream rough edges are named rather than glossed: the seed exits 0 while silently failing 22 reference pages whose sections exceed the 8192-token embedding limit, and a local index has no partner-integration pages because that source reads the hosted misc project. AGENTS.md is the agent-facing version: which loop to run for a given kind of change, the spend rules for anything that costs money, and the same limitations stated as operational guidance. CLAUDE.md points at it. Verified: smoke 27/27, tsc and biome clean.
README gets a "Local development loop" section covering the three agent inputs and how to override each: edit the skills tree and just run, build the mcp repo anywhere and pass --mcp, serve docs from your own supabase/supabase checkout and pass --content-api. It states where the keys go, and that `compare` is a screen rather than causal proof. It also records the one live limitation: `docs seed` needs a docs checkout carrying supabase/supabase#48364, which is still open. Without it fetchAllSources unconditionally awaits the lint-warnings source, whose loader needs the docs GitHub App, and a shared Promise.all turns that into a full abort before any embedding, so a failed attempt costs nothing. Two upstream rough edges are named rather than glossed: the seed exits 0 while silently failing 22 reference pages whose sections exceed the 8192-token embedding limit, and a local index has no partner-integration pages because that source reads the hosted misc project. AGENTS.md is the agent-facing version: which loop to run for a given kind of change, the spend rules for anything that costs money, and the same limitations stated as operational guidance. CLAUDE.md points at it. Verified: smoke 27/27, tsc and biome clean.
README gets a "Local development loop" section covering the three agent inputs and how to override each: edit the skills tree and just run, build the mcp repo anywhere and pass --mcp, serve docs from your own supabase/supabase checkout and pass --content-api. It states where the keys go, and that `compare` is a screen rather than causal proof. It also records the one live limitation: `docs seed` needs a docs checkout carrying supabase/supabase#48364, which is still open. Without it fetchAllSources unconditionally awaits the lint-warnings source, whose loader needs the docs GitHub App, and a shared Promise.all turns that into a full abort before any embedding, so a failed attempt costs nothing. Two upstream rough edges are named rather than glossed: the seed exits 0 while silently failing 22 reference pages whose sections exceed the 8192-token embedding limit, and a local index has no partner-integration pages because that source reads the hosted misc project. AGENTS.md is the agent-facing version: which loop to run for a given kind of change, the spend rules for anything that costs money, and the same limitations stated as operational guidance. CLAUDE.md points at it. Verified: smoke 27/27, tsc and biome clean.
README gets a "Local development loop" section covering the three agent inputs and how to override each: edit the skills tree and just run, build the mcp repo anywhere and pass --mcp, serve docs from your own supabase/supabase checkout and pass --content-api. It states where the keys go, and that `compare` is a screen rather than causal proof. It also records the one live limitation: `docs seed` needs a docs checkout carrying supabase/supabase#48364, which is still open. Without it fetchAllSources unconditionally awaits the lint-warnings source, whose loader needs the docs GitHub App, and a shared Promise.all turns that into a full abort before any embedding, so a failed attempt costs nothing. Two upstream rough edges are named rather than glossed: the seed exits 0 while silently failing 22 reference pages whose sections exceed the 8192-token embedding limit, and a local index has no partner-integration pages because that source reads the hosted misc project. AGENTS.md is the agent-facing version: which loop to run for a given kind of change, the spend rules for anything that costs money, and the same limitations stated as operational guidance. CLAUDE.md points at it. Verified: smoke 27/27, tsc and biome clean.
README gets a "Local development loop" section covering the three agent inputs and how to override each: edit the skills tree and just run, build the mcp repo anywhere and pass --mcp, serve docs from your own supabase/supabase checkout and pass --content-api. It states where the keys go, and that `compare` is a screen rather than causal proof. It also records the one live limitation: `docs seed` needs a docs checkout carrying supabase/supabase#48364, which is still open. Without it fetchAllSources unconditionally awaits the lint-warnings source, whose loader needs the docs GitHub App, and a shared Promise.all turns that into a full abort before any embedding, so a failed attempt costs nothing. Two upstream rough edges are named rather than glossed: the seed exits 0 while silently failing 22 reference pages whose sections exceed the 8192-token embedding limit, and a local index has no partner-integration pages because that source reads the hosted misc project. AGENTS.md is the agent-facing version: which loop to run for a given kind of change, the spend rules for anything that costs money, and the same limitations stated as operational guidance. CLAUDE.md points at it. Verified: smoke 27/27, tsc and biome clean.
I have read the CONTRIBUTING.md file.
YES
What kind of change does this PR introduce?
Bug fix. Complete App configurations produce the same auth options as before.
What is the current behavior?
Without the docs GitHub App private key, two things fail for a contributor:
pnpm run embeddingsaborts before doing any work. The lint warnings source throws, and every source shares onePromise.allinfetchAllSources().pnpm --filter docs buildexits 1 in prebuild, so thenpm run buildpre-flight CONTRIBUTING.md asks for cannot run either:Both read public content, so this is a rate-limit guard rather than access control: App auth landed in #43015 because unauthenticated calls (60 req/hr per IP) went flaky on shared runners.
What is the new behavior?
apps/docs/lib/octokit.auth.tsadds one rung below the App: a token fromGH_TOKEN, thenGITHUB_TOKEN(the precedencegh help environmentdocuments), soexport GH_TOKEN=$(gh auth token)is enough to build locally. Still authenticated, so #43015's fix holds, and still an authenticated Octokit client, so #44274 holds.A partially configured App is now an error naming the missing vars, rather than falling through to a token.
Used by the lint warnings loader and
lib/octokit.ts. The two token vars are declared inapps/docs/turbo.jsoncforturbo/no-undeclared-env-vars.Additional context
With only
GH_TOKENset,turbo run build --filter=docs --forcepasses 4/4 and search-index source loading completes.pnpm testpasses (20 files, 164 tests), andtsc --noEmitpluspnpm run lintmatchorigin/master. For a complete App config the auth options are identical to before. Happy to post the fuller verification as a comment.Summary by CodeRabbit
New Features
GH_TOKENandGITHUB_TOKEN, with clear precedence rules.Bug Fixes