github / github/app

[Bug] GHE.com data residency: built-in PR/issue tools send unauthenticated requests to api.<tenant>.ghe.com (401/403), agent must fall back to gh CLI

オープン
#2,716 コメント 0 件 リアクション 1 件 担当者 0 名 GitHub で見る
主要言語
言語のデータがありません
スター
2.1k
フォーク
153
PR マージ指標
30日以内にマージされた PR はありません

説明

### Short summary
Built-in PR/issue features send unauthenticated API requests to GHE.com (data residency) host, causing 401/403

### Affected version or release
1.1.6 (commit a9706b2)

### Installation context
Windows 11 x64. Signed in with a single GHE.com data-residency account (`9altitudes.ghe.com`), which also holds the Copilot subscription. A secondary github.com account is added but has no Copilot license.

### What happened?
The app resolves the correct GHE.com host for its internal PR/issue tooling, but several internal API calls go out **without credentials**, so they fail with 401/403 anonymous-request errors:

- `create_pull_request` tool:
```
github_app::tools::create_pull_request: Project account repair candidate could not inspect repository for PR creation
login=FlemmingBK host=9altitudes.ghe.com
error=github API request failed (401): Must authenticate to access this API.
```
- PR auto-link loop (`github_api_external_created_pr_lookup`) repeatedly fails:
```
url=https://api.9altitudes.ghe.com/repositories//pulls
status=403 error=github API rate limited (403): API rate limit exceeded for .
(But here's the good news: Authenticated requests get a higher rate limit...)
```
The "rate limit exceeded for " wording confirms the request was anonymous.

Replaying the exact same URL (`https://api.9altitudes.ghe.com/repositories/`) with the OAuth token the app itself provisioned (the one it injects as `GH_TOKEN` for sessions) succeeds — so the token is valid and has access; the app just does not attach it for these calls.

Net effect: built-in create-PR/issue features fail and the agent must fall back to the `gh` CLI, which works because `GH_HOST`/`GH_TOKEN` are injected correctly.

Request IDs (from `github-app..log`):
- 403 anonymous: `F874:EE0A5:C31A1:6D5050:6A787AE1` (2026-08-09 13:04:33 UTC)
- 401 create_pull_request: `D0D6:9A8F9:25D76F:AAAC03:6A75EF50`

### Steps to reproduce
1. Sign in to the Copilot app with a GHE.com data-residency account only (Copilot subscription on that account).
2. Open a project session on a repo hosted on the GHE.com tenant, make a change.
3. Use the built-in create pull request flow (or let the app try to auto-link an externally created PR).
4. Observe 401/403 failures in `~/.copilot/logs/github-app..log` against `api..ghe.com`, and the agent falling back to `gh`.

### Expected behavior
Internal API calls to `api..ghe.com` should carry the same OAuth credentials the app already holds for that host, so built-in PR/issue tooling works on GHE.com the same as on github.com.

### Additional context
- `gh auth status` inside sessions is correct (`GH_HOST=9altitudes.ghe.com`, valid token) — only the app's own internal client is affected.
- Possibly related but distinct: #1441 (ghe.com sign-in), #1131 (OAuth scope on GHEC data residency), #2027 (links open github.com).

コントリビューションガイド

コントリビューションガイドを開く

調査の方向性

create_pull_request と github_api_external_created_pr_lookup のパスから始め、github-app logs を使って api..ghe.com に送信されるリクエストを追跡します。これらの内部リクエストを、gh CLI における GH_HOST/GH_TOKEN の認証済み動作と比較します。組み込みの PR および issue ツールが保持している OAuth credentials を送信し、匿名の 401/403 レスポンスを生成しなくなれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
github
領域
api, authentication
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
静か
明瞭さ
おおむね明確
初心者へのやさしさ
50/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。