Skip to content

fix(cli): emit json for missing agent show#349

Open
OnlyYu1996 wants to merge 1 commit into
CortexLM:mainfrom
OnlyYu1996:fix-agent-show-json-error
Open

fix(cli): emit json for missing agent show#349
OnlyYu1996 wants to merge 1 commit into
CortexLM:mainfrom
OnlyYu1996:fix-agent-show-json-error

Conversation

@OnlyYu1996
Copy link
Copy Markdown

Fixes cortex agent show <missing> --json so the command emits a JSON error object on stdout instead of only relying on the plain text top-level error.

Bounty issue: PlatformNetwork/bounty-challenge#53103

Changes:

  • Add shared missing-agent error helpers for agent show.
  • When --json is set, print { "error": "Agent '<name>' not found" } before returning the existing non-zero error.
  • Keep non-JSON behavior unchanged.
  • Fix the current main read_file_with_encoding test import so agent command tests compile.

Validation:

  • cargo +stable fmt --package cortex-cli --check
  • cargo +stable test --package cortex-cli agent_cmd::handlers::show::tests::test_agent_not_found_json_error -- --nocapture
  • cargo +stable test --package cortex-cli agent_cmd::tests -- --nocapture
  • cargo +stable check --package cortex-cli --lib
  • cargo +stable build --package cortex-cli --bin Cortex
  • real CLI smoke for agent show nonexistent --json stdout JSON parsing and non-JSON behavior
  • git diff --check

Copy link
Copy Markdown

@greptile-apps greptile-apps Bot left a comment

Choose a reason for hiding this comment

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

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant