Skip to content

[Bug]: PR watch never wakes when gh auth token output has extra stdout lines; failed reads never give up and the token is logged #33467

Closed

Description

@anovoselnik

Before submitting

Area

apps/server: GitHubCredentials (gh token lookup) and PullRequestWatchReactor

Steps to reproduce

  1. On Linux, put a gh wrapper ahead of the real gh on the server's PATH. The wrapper writes one line to stdout before it execs gh:
    #!/bin/sh
    echo "hello from wrapper"
    exec /usr/bin/gh "$@"
    (In my case the wrapper ran mise use -g gh, which prints mise ~/.config/mise/config.toml tools: [email protected] to stdout.)
  2. Start T3 Code. From a thread, link_pull_request and then watch_pull_request a GitHub PR. Both return watching: true.
  3. Push a change. Let CI fail, then let it pass.

Expected behavior

  • The token lookup rejects gh auth token output that is not a single token-shaped line, or takes its last non-empty line, and reports a clear credential error.
  • A watch that can never read its PR wakes the thread with "could not read it", as it does for other repeated read failures.
  • Tokens never appear in logs.

Actual behavior

  • GitHubCredentials uses stdout.trim() of gh auth token as the token. The value contains a newline, so Headers.append throws before any request is sent. Every GitHub API call fails with PullRequestProviderError { reason: "failed", detail: "Could not reach GitHub at github.com." }.
  • In PullRequestWatchReactor.readGroup, a "failed" reason clears readFailures before rethrowing, so it never reaches READ_FAILURE_LIMIT and giveUp never runs. The watch stays on, never reads the PR, and never wakes the thread. Failed checks, passing checks and comments all go unreported.
  • The TypeError message includes the full header value, so the GitHub OAuth token is written in plain text to server.trace.ndjson on every 2-minute sweep.

Impact

PR watching is silently broken for every GitHub PR on the machine. Agents end their turn as instructed and are never woken, so users have to prompt every thread waiting on CI. There is no visible error in the UI.

Version or commit

0.1.7 (Linux AppImage)

Environment

Arch Linux (Omarchy), mise 2026.11.4, gh 2.103.3 (via mise), a ~/.local/bin/gh wrapper ahead of the real gh on PATH.

Logs or stack traces

From when a watch ended (it was unwatched by hand after 3 hours):

"pull request watch ended", { "pullRequest": "github.com/<owner>/<repo>#139", "reason": "stopped",
  "minutes": 186, "quietMinutes": 186, "wakes": 0, "reads": 0, "partial": false }

Every sweep (token redacted):

"pull request watch check failed"
PullRequestOperationError(operation: detail)
 -> PullRequestProviderError(provider: github, operation: getChangeRequest, reason: failed,
    detail: "Could not reach GitHub at github.com.")
 -> GitHubApiRequestError(operation: getPullRequestDetail)
 -> GraphQLClientError(PullRequestCore) -> TransportError (POST https://api.github.com/graphql)
 -> TypeError: Headers.append: "Bearer mise ~/.config/mise/config.toml tools: [email protected]\ngho_<REDACTED>" is an invalid header value.

Screenshots, recordings, or supporting files

No response

Workaround

Make sure gh auth token prints only the token. In my case that meant sending the wrapper's mise use output to /dev/null. The 5-minute token cache then picks up a clean token without a restart.

Activity

  1. juliusmarminge commented on Nov 11, 2026

    @juliusmarminge
    Member

    Closing as a local misconfiguration, not a T3 Code bug.

    Your gh wrapper writes to stdout. That breaks every tool that reads gh output, not just T3 Code: gh api ... | jq, $(gh auth token), and any script that parses gh breaks the same way. A wrapper must not touch stdout. Send its output to stderr (>&2) or remove it, and running mise use -g gh on every gh call is a bad idea anyway. Install gh once, or put mise's shims dir on PATH.

    We are not going to guess which line of the output is the real token.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions