Skip to content

Add JSON output for RedisVL CLI read commands#593

Merged
vishal-bala merged 24 commits into
mainfrom
feat/RAAE-1557/cli-json
Apr 30, 2026
Merged

Add JSON output for RedisVL CLI read commands#593
vishal-bala merged 24 commits into
mainfrom
feat/RAAE-1557/cli-json

Conversation

@limjoobin
Copy link
Copy Markdown
Contributor

@limjoobin limjoobin commented Apr 27, 2026

Changes

This PR adds JSON output for RedisVL CLI read commands to make it more machine-readable.

Features added:

  • added the --json flag to rvl version, rvl index listall, rvl index info, and rvl stats.
  • Add shared JSON CLI helpers (add_json_output_flag, cli_print_json) in redisvl/cli/utils.py for consistent one-object stdout behavior.
  • Add/update unit tests for all new JSON paths and error contracts.

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 --json is used, but default behavior is preserved.

Overview
Adds a shared CLI JSON output mode via --json, including new helpers add_json_output_flag and cli_print_json (with safe bytes encoding) to ensure one JSON object on stdout on success.

Extends rvl index info, rvl index listall, and rvl stats to support JSON output: index info now normalizes FT.INFO-style structures into a stable {index_information, index_fields} payload, listall emits {indices: [...]}, and stats emits a full STATS_KEYS-shaped object with missing keys as null, while keeping existing human-readable output when --json is 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.

- 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
@limjoobin limjoobin self-assigned this Apr 27, 2026
@jit-ci
Copy link
Copy Markdown

jit-ci Bot commented Apr 27, 2026

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-ci
Copy link
Copy Markdown

jit-ci Bot commented Apr 27, 2026

🛡️ Jit Security Scan Results

CRITICAL HIGH MEDIUM

✅ No security findings were detected in this PR


Security scan by Jit

@limjoobin limjoobin marked this pull request as ready for review April 27, 2026 07:11
@limjoobin limjoobin changed the title (RAAE-1557) Add JSON output for RedisVL CLI read commands Add JSON output for RedisVL CLI read commands Apr 27, 2026
Comment thread redisvl/cli/index.py
Comment thread redisvl/cli/stats.py Outdated
Copy link
Copy Markdown
Collaborator

@vishal-bala vishal-bala left a comment

Choose a reason for hiding this comment

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

Looks good! Just a couple of minor things

Comment thread redisvl/cli/index.py Outdated
Comment thread redisvl/cli/utils.py Outdated
Comment thread redisvl/cli/version.py Outdated
limjoobin and others added 4 commits April 29, 2026 21:08
Co-authored-by: Vishal Bala <vishal-bala@users.noreply.github.com>
Co-authored-by: Vishal Bala <vishal-bala@users.noreply.github.com>
Copy link
Copy Markdown
Collaborator

@vishal-bala vishal-bala left a comment

Choose a reason for hiding this comment

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

LGTM!

Comment thread tests/unit/test_cli_utils.py
@vishal-bala vishal-bala added the auto:patch Increment the patch version when merged label Apr 29, 2026
Comment thread redisvl/cli/index.py Outdated
Comment thread tests/unit/test_cli_index.py Outdated
Comment thread tests/unit/test_cli_stats.py Outdated
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ 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.

Comment thread redisvl/cli/utils.py Outdated
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
Copy link
Copy Markdown
Collaborator

@vishal-bala vishal-bala Apr 30, 2026

Choose a reason for hiding this comment

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

Why do we have these assertions commented out?

Suggested change
# 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)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
# assert excinfo.value.code == 0 # try/except in Index.__init__ + exit(0)

@vishal-bala vishal-bala merged commit 270b48f into main Apr 30, 2026
57 checks passed
@vishal-bala vishal-bala deleted the feat/RAAE-1557/cli-json branch April 30, 2026 15:55
@applied-ai-release-bot
Copy link
Copy Markdown

🚀 PR was released in v0.18.1 🚀

@applied-ai-release-bot applied-ai-release-bot Bot added the released This issue/pull request has been released. label Apr 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

auto:patch Increment the patch version when merged released This issue/pull request has been released.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants