Repository navigation
fix: emit JSON when --level is warn/fail (#373) - #376
Closed
ranas-mukminov wants to merge 1 commit into
Closed
ranas-mukminov wants to merge 1 commit into
ranas-mukminov wants to merge 1 commit into
Conversation
JSON is written through out.info(), which OutputBuffer drops when --level is above info. Pass always_print=True on all JSON emit sites so -j/--json still produces a parseable document. Adds a unit test covering always_print bypassing the level filter.
Owner
|
Closing as per rationale in: #373 (comment) |
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.
Summary
Fixes #373: combining
--json/-jwith--level=warnor--level=failsilently discards all JSON output (blank line only), even though the exit code remains correct.Root cause
JSON is emitted via
out.info(json.dumps(...)).OutputBuffer._print()drops messages below the configured minimum level unlessalways_print=True. With--level=warn, info-level JSON is filtered out.Fix
Pass
always_print=Trueon all three JSON emit sites inssh_audit.py(standard audit, policy evaluation, and algorithm lookup). This matches the Option A behavior described in #373:--levelcontinues to filter text output; JSON always gets a full document.Test plan
test_outputbuffer_always_print_bypasses_level(level=warn drops info;always_print=Truekeeps it)PYTHONPATH=src pytest test/test_outputbuffer.py— 9 passedout.info(json.dumps(...))call sites now includealways_print=True