Skip to content

feat(bugs): add --format json to bugs show and bugs close#279

Merged
sachiniyer merged 1 commit into
mainfrom
siyer/bugs-show-close-json
May 6, 2026
Merged

feat(bugs): add --format json to bugs show and bugs close#279
sachiniyer merged 1 commit into
mainfrom
siyer/bugs-show-close-json

Conversation

@sachiniyer
Copy link
Copy Markdown
Contributor

Summary

Triage agents repeatedly grep stdout for fields that are already in the JSON payload — bug metadata (file path, security flag, blame, summary) for show, and the resulting BugReview for close. Only bugs list accepted --format json; show and close forced text-parsing.

Add --format <table|json> (default table) to both subcommands:

  • bugs show <id> --format json — emits the full Bug payload (id, title, summary, filePath, introducedIn, review, linkedIssues, …)
  • bugs close <id> --state <s> --format json — emits the resulting BugReview, suppressing the human-friendly "✓ Bug closed as: …" banner so stdout is pure JSON

is_silent extended to suppress auto-update notices on the new JSON paths, matching how bugs list --format json already works.

The table-view body of Show is unchanged; extracted into a render_bug_show helper so the handler match arm just dispatches on format.

Testing

Automated, run locally and passing:

  • cargo test — full suite green. New clap-parse tests in src/lib.rs:
    • silent_when_bugs_show_jsonbugs show … --format json triggers the silent-output path
    • silent_when_bugs_close_json — same for close
    • Existing not_silent_for_bugs_show / not_silent_for_bugs_close still pass (default format is table)
  • cargo clippy -- -D warnings — clean
  • cargo fmt --check — clean
  • cargo xtask check — clean (HELP.md regenerated for the two new flags)

Manual end-to-end against live API:

  • bugs show bug_5d237de8-… --format json → valid JSON, all expected fields present:
    keys: ['createdAt', 'filePath', 'id', 'introducedIn', 'isSecurityVulnerability',
           'linkedIssues', 'repoId', 'summary', 'title']
    
  • bugs show bug_5d237de8-… (default) → unchanged: ID/Title/File/Created/Security/Introduced/Issue rows + markdown summary
  • bugs close bug_e79362bd-… --state dismissed --dismissal-reason not-a-bug --format json (idempotent re-close on an already-dismissed bug) → emits the BugReview JSON only, no ✓ Bug closed as: banner. head -1 of stdout is just {.
  • bugs show bug_does_not_exist --format jsonError: Failed to fetch bug details (still propagates errors via stderr; stdout stays empty)

⚠️ Pre-existing bug found while testing (not part of this PR, flagged for follow-up):
bugs close without --notes overwrites any existing review.notes with null — the API client sends notes: None which the backend treats as "set to null" rather than "leave unchanged". Caught when re-closing an already-dismissed bug for this PR's smoke test; the original notes were restored manually. Not introduced by this PR but tagged for follow-up.

🤖 Generated with Claude Code

@sachiniyer sachiniyer temporarily deployed to integration-tests May 6, 2026 20:59 — with GitHub Actions Inactive
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

No issues found across 3 files

Triage agents repeatedly grep stdout for fields like the closed-via
PR number and bug metadata (file path, security flag, blame). Only
`bugs list` accepted `--format json`; `show` and `close` forced
text-parsing.

Add `--format <table|json>` (default `table`) to both subcommands:
- `bugs show <id> --format json` — emits the full Bug payload
- `bugs close <id> --state <s> --format json` — emits the resulting
  BugReview, suppressing the human "✓ Bug closed as: …" banner so
  stdout is pure JSON

`is_silent` extended to suppress auto-update notices on the new
JSON paths, matching how `bugs list --format json` already works.

The table-view body of `Show` is unchanged; extracted into a
`render_bug_show` helper to keep the handler match arm focused on
the format dispatch.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@sachiniyer sachiniyer force-pushed the siyer/bugs-show-close-json branch from 1a13d1a to 93eaf2d Compare May 6, 2026 22:13
@sachiniyer sachiniyer temporarily deployed to integration-tests May 6, 2026 22:13 — with GitHub Actions Inactive
@sachiniyer sachiniyer enabled auto-merge (squash) May 6, 2026 22:14
@sachiniyer sachiniyer merged commit bd1cda5 into main May 6, 2026
12 checks passed
@sachiniyer sachiniyer deleted the siyer/bugs-show-close-json branch May 6, 2026 22:16
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