Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

[bug] GitHub App installation tokens (ghs_) are rejected by the credential preflight

Đang mở
#1,661 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
48/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
github, typescript
Lĩnh vực
authentication, backend

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

bug triage needed
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
  1. Register a GitHub App, install it on an organisation, grant Contents: read and
    Metadata: read.
  2. Mint an installation token:
    POST /app/installations/{installation_id}/access_tokens (returns a ghs_… token).
  3. Configure a GitHub connector with that token and an orgs entry:
    { "type": "github", "token": { "env": "GITHUB_TOKEN" }, "orgs": ["my-org"] }
    
  4. 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.listForAuthenticatedUserGET /user/repos (github.ts:251)
  • rest.search.reposGET /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.

Ngôn ngữ chính
TypeScript
Star
3.9k
Fork
374
Merge trung bình
21 giờ 18 phút
Pull request đã merge (30 ngày)
39

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của sourcebot-dev/sourcebot

Tất cả issue của sourcebot-dev/sourcebot

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.