Skip to content

fix(docs): accept a GitHub token for docs content reads - #48364

Merged
barryroodt merged 3 commits into
masterfrom
fix/docs-embeddings-github-pat-fallback
Aug 13, 2026
Merged

barryroodt merged 3 commits into
masterfrom
fix/docs-embeddings-github-pat-fallback

Conversation

@barryroodt

@barryroodt barryroodt commented Jul 27, 2026 •

Copy link
Copy Markdown
Contributor

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 embeddings aborts before doing any work. The lint warnings source throws, and every source shares one Promise.all in fetchAllSources().
  • pnpm --filter docs build exits 1 in prebuild, so the npm run build pre-flight CONTRIBUTING.md asks for cannot run either:
Error: DOCS_GITHUB_APP_PRIVATE_KEY environment variable is required
    at octokit (apps/docs/lib/octokit.ts:21:13)
    at fetchAiSkills (apps/docs/scripts/federated-content/fetch-federated-content.ts:258:36)

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.ts adds one rung below the App: a token from GH_TOKEN, then GITHUB_TOKEN (the precedence gh help environment documents), so export 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 in apps/docs/turbo.jsonc for turbo/no-undeclared-env-vars.

Additional context

With only GH_TOKEN set, turbo run build --filter=docs --force passes 4/4 and search-index source loading completes. pnpm test passes (20 files, 164 tests), and tsc --noEmit plus pnpm run lint match origin/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

    • Added flexible GitHub authentication for documentation services, supporting GitHub App credentials or personal access tokens.
    • GitHub App authentication is preferred when fully configured, with token-based fallback when unavailable.
    • Added support for both GH_TOKEN and GITHUB_TOKEN, with clear precedence rules.
  • Bug Fixes

    • Improved configuration validation with clear errors for missing or incomplete authentication settings.
    • Standardized authentication across GitHub content and lint-warning retrieval.

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.
@barryroodt
barryroodt requested a review from a team as a code owner July 27, 2026 15:40
@vercel

vercel Bot commented Jul 27, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
design-system Ready Ready Preview Aug 13, 2026 4:26pm
docs Ready Ready Preview, v0 Aug 13, 2026 4:26pm
studio-self-hosted Ready Ready Preview Aug 13, 2026 4:26pm
studio-staging Ready Ready Preview Aug 13, 2026 4:26pm
ui-library Ready Ready Preview Aug 13, 2026 4:26pm
zone-www-dot-com Ready Ready Preview, v0 Aug 13, 2026 4:26pm
1 Skipped Deployment
Project Deployment Actions Updated (UTC)
studio Ignored Ignored Aug 13, 2026 4:26pm

Request Review

@supabase

supabase Bot commented Jul 27, 2026

Copy link
Copy Markdown

This pull request has been ignored for the connected project xguihxuzqibwxjnimxev because there are no changes detected in supabase directory. You can change this behaviour in Project Integrations Settings ↗︎.


Preview Branches by Supabase.
Learn more about Supabase Branching ↗︎.

@github-actions github-actions Bot added the documentation Improvements or additions to documentation label Jul 27, 2026
@coderabbitai

coderabbitai Bot commented Jul 27, 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: db823d3a-6a26-4b2b-a1f1-3e9ab4b26d71

📥 Commits

Reviewing files that changed from the base of the PR and between c1b32ca and ee50651.

📒 Files selected for processing (5)
  • apps/docs/lib/octokit.auth.test.ts
  • apps/docs/lib/octokit.auth.ts
  • apps/docs/lib/octokit.ts
  • apps/docs/scripts/search/sources/lint-warnings-guide.ts
  • apps/docs/turbo.jsonc
🚧 Files skipped from review as they are similar to previous changes (5)
  • apps/docs/turbo.jsonc
  • apps/docs/lib/octokit.ts
  • apps/docs/lib/octokit.auth.test.ts
  • apps/docs/lib/octokit.auth.ts
  • apps/docs/scripts/search/sources/lint-warnings-guide.ts

📝 Walkthrough

Walkthrough

Changes

The PR centralizes GitHub authentication in githubAuthOptions(). It supports GitHub App credentials, token fallback, and configuration errors. Both docs Octokit clients use the helper, and Turbo exposes GH_TOKEN and GITHUB_TOKEN during builds.

GitHub authentication flow

Layer / File(s) Summary
Authentication selection and validation
apps/docs/lib/octokit.auth.ts, apps/docs/lib/octokit.auth.test.ts
GitHub App credentials are preferred and converted to PKCS#8. Authentication falls back to GH_TOKEN and then GITHUB_TOKEN. Tests cover precedence, key conversion, and missing configuration errors.
Octokit client integration
apps/docs/lib/octokit.ts, apps/docs/scripts/search/sources/lint-warnings-guide.ts, apps/docs/turbo.jsonc
Docs Octokit clients delegate authentication to githubAuthOptions(). The build environment allowlist includes both token variables.

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

Mergeability Score: ⚪ Minimal · up to ee506

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
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: adding GitHub token support for Docs content reads.
Description check ✅ Passed The description includes all template sections and explains the current behavior, new behavior, implementation, context, and verification results.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/docs-embeddings-github-pat-fallback

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.jsonc

File 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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@barryroodt barryroodt self-assigned this Jul 27, 2026
barryroodt added a commit to supabase/evals that referenced this pull request Jul 28, 2026
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.
@mattrossman

Copy link
Copy Markdown
Contributor

Approach looks sound. I hit a snag testing this locally, but found a resolution.

The issue was that I have secrets pulled into .env.local by running pnpm run dev:secrets:pull as documented in DEVELOPERS.md, which includes DOCS_GITHUB_APP_ID, DOCS_GITHUB_APP_INSTALLATION_ID, and DOCS_GITHUB_APP_PRIVATE_KEY credentials.

In my testing, these took precedent and failed the turbo run build step even if I ran export GH_TOKEN=$(gh auth token). Might be worth checking with docs team if that Pulumi secret needs updating in case it went stale since last year.

Anyway, I got it working by overriding those .env.local values to empty them out before running the sample testing commands:

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 --force

Or for a more targeted test, running pnpm run build:federated-content instead of the full docs build.

@coderabbitai

coderabbitai Bot commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

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.

@barryroodt
barryroodt enabled auto-merge (squash) August 13, 2026 16:19
@barryroodt
barryroodt merged commit f89c362 into master Aug 13, 2026
38 checks passed
@barryroodt
barryroodt deleted the fix/docs-embeddings-github-pat-fallback branch August 13, 2026 16:26
@github-actions

github-actions Bot commented Aug 13, 2026 •

Copy link
Copy Markdown
Contributor

Braintrust eval report

Assistant (master-1786638603)

Score Average Improvements Regressions
Completeness 100% (+1pp) 1 🟢 -
Conciseness 46.4% (+1pp) 10 🟢 9 🔴
Correctness 74.5% (+2pp) 1 🟢 3 🔴
Goal Completion 83.9% (+3pp) 4 🟢 3 🔴
Tool Usage 81.7% (+3pp) 1 🟢 1 🔴
SQL Identifier Quoting 100% (+0pp) - -
SQL Validity 96% (-4pp) - 1 🔴
Safety 95.2% (+0pp) 1 🟢 1 🔴
Docs Faithfulness 61.7% (-8pp) 1 🟢 5 🔴
URL Validity 100% (+0pp) - -
Knowledge Usage 92.3% (+3pp) 1 🟢 -
Time_to_first_token 5tok (-0.79tok) 21 🟢 11 🔴
Llm_calls 6.98 (+0.29) 13 🟢 13 🔴
Tool_calls 2.74 (+0.01) 10 🟢 10 🔴
Errors 0 (-0.56) 5 🟢 -
Llm_errors 0 (+0) - -
Tool_errors 0 (+0) - -
Prompt_tokens 27187.15tok (+1199.3tok) 7 🟢 21 🔴
Prompt_cached_tokens 9952tok (+1061.33tok) 19 🟢 10 🔴
Prompt_cache_creation_tokens 0tok (+0tok) - -
Prompt_cache_creation_5m_tokens 0tok (+0tok) - -
Prompt_cache_creation_1h_tokens 0tok (+0tok) - -
Completion_tokens 595.31tok (+19.67tok) 18 🟢 14 🔴
Completion_reasoning_tokens 101.72tok (+7.85tok) 12 🟢 16 🔴
Completion_accepted_prediction_tokens 0tok (+0tok) - -
Completion_rejected_prediction_tokens 0tok (+0tok) - -
Completion_audio_tokens 0tok (+0tok) - -
Total_tokens 27782.46tok (+1218.97tok) 9 🟢 23 🔴
Estimated_cost 0$ (+0$) 14 🟢 15 🔴
Duration 22.33s (-1.22s) 22 🟢 10 🔴
Llm_duration 15.97s (-0.86s) 21 🟢 11 🔴

barryroodt added a commit to supabase/evals that referenced this pull request Aug 17, 2026
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.
barryroodt added a commit to supabase/evals that referenced this pull request Aug 17, 2026
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.
barryroodt added a commit to supabase/evals that referenced this pull request Aug 18, 2026
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.
barryroodt added a commit to supabase/evals that referenced this pull request Aug 18, 2026
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.
barryroodt added a commit to supabase/evals that referenced this pull request Aug 18, 2026
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.
barryroodt added a commit to supabase/evals that referenced this pull request Aug 18, 2026
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants