Skip to content

Write diagnostic warnings to stderr instead of stdout#1682

Open
jedisct1 wants to merge 7 commits intomainfrom
fdenis/expwarning
Open

Write diagnostic warnings to stderr instead of stdout#1682
jedisct1 wants to merge 7 commits intomainfrom
fdenis/expwarning

Conversation

@jedisct1
Copy link
Contributor

@jedisct1 jedisct1 commented Mar 11, 2026

Change summary

Expiration warnings, profile-not-found warnings, and config permission warnings were written to stdout, which broke JSON parsing when --json was used. Now warnings go to stderr instead.

All Submissions:

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same update/change?

Changes to Core Features:

  • Have you written new tests for your core changes, as applicable?
  • Have you successfully run tests with your changes locally?

User Impact

Users piping CLI output through jq or other JSON parsers will no longer encounter parse errors caused by diagnostic warnings mixed into stdout.

Are there any considerations that need to be addressed for release?

No breaking changes.

Expiration warnings, profile-not-found warnings, and config permission
warnings were written to data.Output (stdout), breaking JSON parsing
when --json was used.
@jedisct1 jedisct1 requested a review from a team as a code owner March 11, 2026 10:15
@jedisct1 jedisct1 requested a review from philippschulte March 11, 2026 10:15
@jedisct1 jedisct1 added the Skip-Changelog do not add a changelog entry for this change label Mar 11, 2026
Copy link
Member

@philippschulte philippschulte left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do the tests really verify the regression, because most of them set ErrOutput to the same buffer as Output. I don't think they catch accidental writes to stdout.

Maybe it would be good to add a test with separate stdout/stderr buffers and assert that warnings land only in stderr while stdout remains valid JSON?

@jedisct1
Copy link
Contributor Author

Maybe it would be good to add a test with separate stdout/stderr buffers and assert that warnings land only in stderr while stdout remains valid JSON?

Added, thanks!

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

Labels

Skip-Changelog do not add a changelog entry for this change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants