t3code icon indicating copy to clipboard operation
t3code copied to clipboard

PR read errors for an inaccessible private repo don't name the GitHub account used, and a stopped watch never resumes

Open kinton opened this issue 4 days ago • 1 comments

What happened

A linked PR in a private org repo stopped being watched: "T3 Code stopped watching pull request #N because it failed to read it from the host 8 times in a row". pull_request_read on the same PR kept failing with:

GitHub could not find the requested resource, or the credential cannot see it. GitHub said: Could not resolve to a Repository with the name 'org/repo'. (at repository)

gh in a terminal could read the PR. The error never says which GitHub account T3 used, so it took a long time to find that T3 was reading as the wrong one of two logged-in gh accounts.

Diagnosis

gh has two github.com accounts: A (active) cannot see the org, B can. GitHubCredentials runs gh auth token --hostname github.com without --user (no account chosen in Settings), so it gets A's token. GitHub answers 404 for a private repo the token cannot see, and the error is passed through as is. captureVerifiedCredential already knows the viewer login from GET /user (getRoutingIdentity), but it does not reach the message or the watch-stop notice.

After gh auth switch -u B, reads kept failing for up to 5 minutes (TOKEN_TTL in GitHubCredentials), then worked with no restart. The watch that had stopped did not come back by itself.

Steps to reproduce

  1. gh auth login with two github.com accounts. Make A active. Only B can see private repo org/repo.
  2. Leave the GitHub account in Settings → Source control & issues unset.
  3. Link org/repo#N to a thread and call watch_pull_request.
  4. See 8 read failures, then the watch stops. Neither the stop notice nor the pull_request_read error names account A.

Expected

  • On a 404 or "Could not resolve to a Repository", the error says which account was used and how to change it, e.g. "read as A (gh active account); choose another account in Settings → Source control & issues".
  • A watch stopped for read failures resumes, or says how to resume it, once the credential changes.

Version

0.1.13 (desktop app, local server)

Environment

macOS 27.2.1, arm64. gh 2.105.0, two github.com accounts.

Evidence

  • server.trace.ndjson: 131 listPullRequestsByHead calls to the org repo returned 404 over one afternoon. Successful calls in the same period went to other repos.
  • T3's rate-limit counters (github.ratelimit.used, github.ratelimit.reset) matched account A's gh api rate_limit exactly, not B's.

Related

#14123 and #17004 (per-checkout or per-owner accounts, closed as a feature request), #31887 (no way to restart a stopped watch from the header), #19549 and #22966 (watch stops on token permission failures).

Workaround

Choose account B in Settings → Source control & issues, or gh auth switch -u B and wait up to 5 minutes. Then call watch_pull_request again.

kinton avatar Nov 27 '26 16:11 kinton

[!NOTE] 🤖 Claude Fable 5.2 responding on behalf of Gigioxx

Same failure on another install, through a different credential path, with numbers on how far it spreads when many threads watch PRs.

What happened here. T3 read GitHub with a saved credential override from Settings → Source control that could not see a private org. gh on the same machine could. For 5 days (2026-11-18 22:49Z to 2026-11-24 16:06Z) every watch on that org's PRs ended with "failed to read it from the host 8 times in a row". It stopped when the override was disabled and T3 fell back to the gh login.

Scale, measured from the agent session logs on this machine:

Stop notices 161, across 51 threads and 119 PRs in 7 repos
Watch call to stop notice 13.1 min median (8 sweeps at 2 min)
Wakes delivered in the window 1 of 192 watches
Wakes delivered outside it about 669 of 720 watches
Threads that watched again 38, and 35 of those stopped again about 13 min later

Why it took 5 days to find. The notice names no error and no account, so the agents assumed a rate limit and waited or watched again. The source says otherwise: a rate-limited read returns before the failure counter (PullRequestWatchReactor.ts L675), so 8 failures means something else. Nothing on screen says that.

What would have caught it on day 1 (the first two are this issue's "Expected"; the third is new):

  1. The stop notice names the failure reason and the account or credential used.
  2. A watch stopped for read failures resumes when the credential changes, or keeps retrying with a backoff.
  3. When every watched PR on a host fails in the same sweep, treat it as one credential fault: say so once, and end no watches.

Limits: T3's own logs for that window are gone, so the error class (not found or forbidden) is inferred from what the agents reported at the time, not read from a trace. The build that ran then is unknown (nightlies); today it is 0.1.14-nightly.20261127.

Gigioxx avatar Nov 27 '26 18:11 Gigioxx