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

Đang mở
#2,716 0 bình luận 1 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
Không có dữ liệu ngôn ngữ
Star
2.1k
Fork
153
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

### 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).

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

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

Hướng nghiên cứu

Bắt đầu với các đường dẫn create_pull_request và github_api_external_created_pr_lookup, sử dụng github-app logs để theo dõi các request được gửi tới api..ghe.com. So sánh các request nội bộ đó với hành vi đã xác thực của GH_HOST/GH_TOKEN trong gh CLI; hoàn tất khi các công cụ PR và issue tích hợp gửi các thông tin xác thực OAuth đang được giữ và không còn tạo ra các phản hồi 401/403 ẩn danh.

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

Đánh giá

Công nghệ
github
Lĩnh vực
api, authentication
Loại issue
Lỗi
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Ít trao đổi
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
50/100

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.