Fix: Redirect GitHub App token refresh logs to stderr to prevent invalid JSON output - #11
Open
lincai505011-ops wants to merge 1 commit into
Open
Fix: Redirect GitHub App token refresh logs to stderr to prevent invalid JSON output#11lincai505011-ops wants to merge 1 commit into
lincai505011-ops wants to merge 1 commit into
Conversation
Token refresh progress messages were written to stdout, corrupting JSON output when consumed by automation/CI pipelines. Fix: AuthTokenRefresher now writes all progress and log messages to ErrOut (defaulting to os.Stderr), keeping stdout clean for machine-readable command output such as JSON payloads. Fixes madalynerlge2#1
|
😅 Unfortunately there are no rewards left to claim in this issue! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
/claim #1
What
Fix: Redirect GitHub App token refresh logs to
stderrto prevent invalid JSON output.Root Cause
When the GitHub App installation token expired during CLI operations, the
AuthTokenRefresherwrote progress messages ("Refreshing GitHub App token...", "Token refresh complete.", "Checking token expiration...") toos.Stdout. This corrupted JSON output consumed by automation/CI pipelines, causing parse failures.Fix
ErrOut io.Writerfield toAuthTokenRefresher, defaulting toos.StderrErrOutinstead ofos.StdoutHTTPClientexposesStdoutandStderrwriters for testabilityDoJSON()helper validates that JSON output is clean (no log pollution)Tests Added
TestTokenRefreshLogsGoToStderr— verifies refresh logs go to stderr, not stdoutTestNonExpiredTokenNoLogPollution— verifies clean stdout when no refresh neededTestDoJSONReturnsCleanOutput— verifies JSON parse succeeds with stderr logging