Add JSON output for RedisVL CLI read commands#593
Conversation
- add_json_output_flag for --json on argparse parsers - cli_print_json for single-object stdout; bytes-safe default Made-with: Cursor
Print {"version": <package>} to stdout; --json overrides --short
Made-with: Cursor
- tests for add_json_output_flag, cli_print_json, Version Made-with: Cursor
Made-with: Cursor
Made-with: Cursor
Made-with: Cursor
Made-with: Cursor
|
Hi, I’m Jit, a friendly security platform designed to help developers build secure applications from day zero with an MVS (Minimal viable security) mindset. In case there are security findings, they will be communicated to you as a comment inside the PR. Hope you’ll enjoy using Jit. Questions? Comments? Want to learn more? Get in touch with us. |
🛡️ Jit Security Scan Results✅ No security findings were detected in this PR
Security scan by Jit
|
vishal-bala
left a comment
There was a problem hiding this comment.
Looks good! Just a couple of minor things
Co-authored-by: Vishal Bala <vishal-bala@users.noreply.github.com>
Co-authored-by: Vishal Bala <vishal-bala@users.noreply.github.com>
This reverts commit ddcd751.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 9e8790b. Configure here.
| with pytest.raises(SystemExit) as excinfo: # exit(0) in Index.__init__ is not a plain return | ||
| Index() | ||
| assert excinfo.value.code == 0 # "log and exit(0)" CLI contract | ||
| # assert excinfo.value.code == 0 # "log and exit(0)" CLI contract |
There was a problem hiding this comment.
Why do we have these assertions commented out?
| # assert excinfo.value.code == 0 # "log and exit(0)" CLI contract |
| ) | ||
| with pytest.raises(SystemExit) as excinfo: | ||
| Index() | ||
| # assert excinfo.value.code == 0 # try/except in Index.__init__ + exit(0) |
There was a problem hiding this comment.
| # assert excinfo.value.code == 0 # try/except in Index.__init__ + exit(0) |
|
🚀 PR was released in |

Changes
This PR adds JSON output for RedisVL CLI read commands to make it more machine-readable.
Features added:
--jsonflag torvl version,rvl index listall,rvl index info, andrvl stats.add_json_output_flag,cli_print_json) inredisvl/cli/utils.pyfor consistent one-object stdout behavior.Note
Low Risk
Adds optional output formatting for CLI read commands without changing index/data operations. Main risk is minor: downstream scripts may depend on exact stdout text when
--jsonis used, but default behavior is preserved.Overview
Adds a shared CLI JSON output mode via
--json, including new helpersadd_json_output_flagandcli_print_json(with safebytesencoding) to ensure one JSON object on stdout on success.Extends
rvl index info,rvl index listall, andrvl statsto support JSON output:index infonow normalizesFT.INFO-style structures into a stable{index_information, index_fields}payload,listallemits{indices: [...]}, andstatsemits a fullSTATS_KEYS-shaped object with missing keys asnull, while keeping existing human-readable output when--jsonis not used.Adds unit tests covering JSON vs table behavior, key ordering/normalization, bytes decoding, and ensuring no partial JSON is printed on error paths.
Reviewed by Cursor Bugbot for commit e1d2bcf. Bugbot is set up for automated code reviews on this repo. Configure here.