Repository navigation
fix(ls): keep JSON delimiters when --quiet is used - #1219
Open
pcbeingused333 wants to merge 1 commit into
Open
pcbeingused333 wants to merge 1 commit into
pcbeingused333 wants to merge 1 commit into
Conversation
Fixes Backblaze#1215 Signed-off-by: Alex Castillo <alex.castillog33@gmail.com>
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.
Fixes #1215
Cause.
b2 ls --jsonprints the array brackets and the separating commas withself._print(...), which is suppressed by--quiet, while each entry goes through_print_json(which setsenforce_output=True). With--quietthe output is therefore a run of bare objects without[,,and], which is not valid JSON.Fix. Pass
enforce_output=Truefor the[,,and]delimiters inls --json, so the whole document is treated as data output like the entries themselves. Nothing else changes.Tests. New
test_ls__json__valid_with_quietintest/unit/console_tool/test_ls.py: 0, 1 and 2 files, with and without--quiet, parsing stdout withjson.loads. The--quietcases fail on main with a JSON decode error. A news fragment is added inchangelog.d/1215.fixed.md.Reproduction.
b2 ls --json --quiet b2://my-bucket | python -m json.toolon a bucket with at least one file (or an empty one, which prints nothing instead of[]) fails on main and succeeds with this change.This change was prepared with the help of an AI coding assistant (Claude) and submitted on Alex's behalf; the author has not independently reviewed or run it beyond the automated tests.