[bug] GitHub App installation tokens (ghs_) are rejected by the credential preflight
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 48/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- github, typescript
- Ambito
- authentication, backend
Direzione di ricerca
Start in packages/backend/src/github.ts at getGitHubReposFromConfig and the GET /user preflight around lines 115 and 185; compare the existing token detection and authentication handling in github.ts and utils.ts:163-177. Check the existing GitHub token-type unit test and verify that a ghs_ token can discover repositories without the user-only preflight failing; consider the users: paths at lines 251 and 322 as additional scope.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Describe the bug
Sourcebot recognises GitHub App installation tokens as a supported token type —
GitHubTokenType declares 'app_installation' and detectGitHubTokenType() returns it
for the ghs_ prefix (packages/backend/src/github.ts:26,43), with a unit test asserting
exactly that.
However, a connector configured with one fails before listing a single repository.
getGitHubReposFromConfig validates the credential with GET /user (github.ts:185) and
rethrows on failure. An installation token authenticates as an installation, not a user,
so GitHub answers:
403 "Resource not accessible by integration"
No permission grant can satisfy this, because there is no user to return. The check also
cannot be skipped: its guard is isAuthenticated: !!token (github.ts:115), so the only
way to avoid it is to configure no token at all — which limits indexing to public
repositories.
Expected: a connector configured with an installation token indexes normally.
Actual: repository discovery aborts with a 403 at the preflight.
The inconsistency is the bug: every other GitHub path already handles installation
tokens correctly. getRepoAuth builds x-access-token: <token> git credentials from one
(utils.ts:163-177), which is precisely the documented form for installation tokens, and
repos.listForOrg accepts one. Only the preflight rejects it.
Note - The credential is simply an installation token supplied as an ordinary
connector token.
To reproduce
- Register a GitHub App, install it on an organisation, grant
Contents: readand
Metadata: read. - Mint an installation token:
POST /app/installations/{installation_id}/access_tokens(returns aghs_…token). - Configure a GitHub connector with that token and an
orgsentry:{ "type": "github", "token": { "env": "GITHUB_TOKEN" }, "orgs": ["my-org"] } - Start Sourcebot and trigger a connection sync.
Result: sync fails immediately. Logs show Failed to authenticate with GitHub and a 403
Resource not accessible by integration. Zero repositories are discovered.
Substituting a personal access token for the same organisation works, which isolates the
failure to the token type rather than to permissions or configuration.
Sourcebot deployment information
Sourcebot version (e.g. v3.0.1): v5.1.12 (docker.sourcebot.dev/sourcebot-dev/sourcebot),
also reproduced against main at the time of writing.
Additional information
Two further user-context calls exist in the same file and will fail the same way for the
same reason, though only when users: is configured rather than orgs::
repos.listForAuthenticatedUser→GET /user/repos(github.ts:251)rest.search.repos→GET /search/repositories?q=user:…(github.ts:322)
A fix for the preflight is proposed in the linked pull request. Happy to extend it to
those two paths if you would prefer them handled in the same change.
- Lingua principale
- TypeScript
- Stelle
- 3.9k
- Fork
- 374
- Merge medio
- 21h 18m
- PR unite (30g)
- 39
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di sourcebot-dev/sourcebot
-
bug triage needed
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
sourcebot-dev/sourcebot#1681 · 1 commento ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
sourcebot-dev/sourcebot#1633 ·
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
sourcebot-dev/sourcebot#1384 · 4 commenti ·
-
ask_sb bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
sourcebot-dev/sourcebot#1137 · 4 commenti ·
-
Feature
Difficoltà 4/5 3-5 giorni Idoneità per principianti 50/100
sourcebot-dev/sourcebot#1659 · 1 commento ·
Tutte le issue di sourcebot-dev/sourcebot
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
safetrustcr/dApp-SafeTrust#426 ·
-
area:workflow bug ready-for-agent
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
fil-donadoni/tolaria#4409 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
Fission-AI/OpenSpec#1960 ·
-
Add dependabot Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
corsairdev/corsair#1764 ·