📝 Description
When executing CLI commands (such as gh repo clone or API queries) using GitHub App authentication, an automatic token refresh can trigger if the installation token has expired.
Currently, the progress and informational log messages generated during this authentication refresh flow are written to stdout instead of stderr. When automation tools or CI/CD pipelines run these commands expecting clean, machine-readable output (such as JSON), the stream becomes corrupted with plain-text log messages. This results in JSON parsing failures and breaks downstream automation.
This issue is a regression that specifically impacts non-interactive environments and automation pipelines utilizing GitHub App authentication.
🎯 Acceptance Criteria
🛠️ Technical Specifications & Context
The repository madalynerlge2/cli is a Go-based command-line interface. The issue likely resides in the authentication flow or the HTTP client round-tripper where token refresh logic is implemented.
Key Areas to Investigate:
- HTTP Client & Auth Round Tripper:
- Check
api/client.go or the package handling HTTP transport/round-tripping (likely in api/ or internal/config/).
- Look for where the GitHub App installation token refresh is intercepted and performed.
- Logging/Output Stream:
- Identify where the refresh progress messages (e.g., "Refreshing token...") are printed.
- Ensure these messages use the
IOStreams.ErrOut stream from the command context instead of fmt.Println, os.Stdout, or a standard logger configured to write to standard output.
- If the refresh logic does not have access to
IOStreams, it should default to writing to os.Stderr rather than os.Stdout.
🧪 Verification & Testing
Manual Verification
- Configure the CLI to use GitHub App authentication.
- Manually expire the installation token (or mock an expired token state in the configuration).
- Run a command expecting JSON output, redirecting
stdout to a file:
gh repo clone <repo> --json --some-flag > output.json
- Verify that:
- The token refresh log messages are printed to the terminal screen (
stderr).
- The
output.json file contains only valid JSON (or is empty if the command doesn't write to stdout on clone, but contains no auth logs).
Automated Test Cases
- Add a unit/integration test in the auth or API package that mocks an expired token.
- Assert that during the round-trip refresh, no bytes are written to the stdout buffer, and all log output is captured in the stderr buffer.

This repo is using Opire - what does it mean? 👇
💵 Everyone can add rewards for this issue commenting /reward 100 (replace 100 with the amount).
🕵️♂️ If someone starts working on this issue to earn the rewards, they can comment /try to let everyone know!
🙌 And when they open the PR, they can comment /claim #1 either in the PR description or in a PR's comment.
🪙 Also, everyone can tip any user commenting /tip 20 @madalynerlge2 (replace 20 with the amount, and @madalynerlge2 with the user to tip).
📖 If you want to learn more, check out our documentation.
📝 Description
When executing CLI commands (such as
gh repo cloneor API queries) using GitHub App authentication, an automatic token refresh can trigger if the installation token has expired.Currently, the progress and informational log messages generated during this authentication refresh flow are written to
stdoutinstead ofstderr. When automation tools or CI/CD pipelines run these commands expecting clean, machine-readable output (such as JSON), the stream becomes corrupted with plain-text log messages. This results in JSON parsing failures and breaks downstream automation.This issue is a regression that specifically impacts non-interactive environments and automation pipelines utilizing GitHub App authentication.
🎯 Acceptance Criteria
stderr(or the configuredErrOutstream).stdoutmust remain completely clean of authentication logs, containing only the command's primary output (e.g., JSON payloads or standard command output).gh repo clone.🛠️ Technical Specifications & Context
The repository
madalynerlge2/cliis a Go-based command-line interface. The issue likely resides in the authentication flow or the HTTP client round-tripper where token refresh logic is implemented.Key Areas to Investigate:
api/client.goor the package handling HTTP transport/round-tripping (likely inapi/orinternal/config/).IOStreams.ErrOutstream from the command context instead offmt.Println,os.Stdout, or a standard logger configured to write to standard output.IOStreams, it should default to writing toos.Stderrrather thanos.Stdout.🧪 Verification & Testing
Manual Verification
stdoutto a file:stderr).output.jsonfile contains only valid JSON (or is empty if the command doesn't write to stdout on clone, but contains no auth logs).Automated Test Cases
This repo is using Opire - what does it mean? 👇
💵 Everyone can add rewards for this issue commenting
/reward 100(replace100with the amount).🕵️♂️ If someone starts working on this issue to earn the rewards, they can comment
/tryto let everyone know!🙌 And when they open the PR, they can comment
/claim #1either in the PR description or in a PR's comment.🪙 Also, everyone can tip any user commenting
/tip 20 @madalynerlge2(replace20with the amount, and@madalynerlge2with the user to tip).📖 If you want to learn more, check out our documentation.