OCM-23148 | fix: format errors and warnings as JSON on stderr when --output flag is set#3226
OCM-23148 | fix: format errors and warnings as JSON on stderr when --output flag is set#3226mmahut wants to merge 1 commit intoopenshift:masterfrom
Conversation
|
Hi @mmahut. Thanks for your PR. I'm waiting for a openshift member to verify that this patch is reasonable to test. If it is, they should reply with Tip We noticed you've done this a few times! Consider joining the org to skip this step and gain Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
/ok-to-test |
|
@mmahut thanks for this PR, I left some comments and would like to requests that you:
|
40c87f0 to
6389497
Compare
|
Hello @olucasfreitas, Thank you for your comments! I have amended the commit message as well as did update the PR description to use the entire template. |
|
/retest |
|
@mmahut: The following tests failed, say
Full PR test history. Your PR dashboard. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
Fixes GitHub issue openshift#3193.
|
/approve |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: mmahut, olucasfreitas The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
@mmahut thanks for the PR, approved and just waiting for merge |
PR Summary
Respect
--outputfor runtime errors and warnings so commands do not emit plain reporter output when machine-readable output is requested.Detailed Description of the Issue
When
--output jsonor--output yamlis used, some runtime error and warning paths still go through the standard reporter and print human-readable output such asE:orW:lines. That breaks automation expecting structured output.This was reported in
rosa whoami --output json, where authentication failures produced plain text instead of JSON. The issue is not limited to a single command path, so this change updates the runtime reporter behavior rather than fixing only one command.Related Issues and PRs
Type of Change
Previous Behavior
Commands invoked with
--output jsonor--output yamlcould still print plain reporter-formatted errors and warnings.Example:
Behavior After This Change
Runtime-reported errors and warnings now honor
--outputand are emitted as structured JSON onstderr, while the default non-structured behavior remains unchanged.Example:
How to Test (Step-by-Step)
Preconditions
rosalogin tokenTest Steps
./rosa whoami --output json./rosa whoami--output jsonor--output yamlExpected Results
./rosa whoami --output jsonprints a valid JSON error object./rosa whoamikeeps the existing human-readable reporter outputProof of the Fix
Breaking Changes
Breaking Change Details / Migration Plan
N/A
Developer Verification Checklist
[JIRA-TICKET] | [TYPE]: <MESSAGE>.make testpasses.make lintpasses.make rosapasses.