Skip to content

fix(cli): report arg errors on stdout as JSON for machine formats (closes #315)#318

Merged
Wolfvin merged 1 commit into
mainfrom
fix/issue-315-cli-error-stdout
Jul 18, 2026
Merged

fix(cli): report arg errors on stdout as JSON for machine formats (closes #315)#318
Wolfvin merged 1 commit into
mainfrom
fix/issue-315-cli-error-stdout

Conversation

@Wolfvin

@Wolfvin Wolfvin commented Jul 18, 2026

Copy link
Copy Markdown
Owner

Closes #315. Found by dogfooding (north-star #279).

Masalah

argparse error → stderr, stdout kosong. Agent yang parse stdout dapat nol byte = simpul "tak ada hasil", bukan error. Silent-wrong, kelas #293/#300.

$ codelens search . --mode symbol execute --format compact
# sebelum: stdout kosong, error di stderr
# sesudah: {"s":"error","error":"unrecognized arguments: execute","error_type":"cli_argument",...}

Fix

_StdoutErrorParser emit {"s":"error",...} ke stdout untuk machine format (json/compact/ai/sarif/…); human mode tetap stderr ramah. Terapkan ke main parser + subparsers.

Bonus: 3 test vacuous ter-ekspos & diperbaiki

Perubahan ini mengungkap 3 test di test_hybrid_engine yang tak pernah menguji apapun: mereka memakai invocation pra-#195 (impact X <ws>, dead-code <ws> yang sudah di-drop) yang selalu error, dan lolos hanya karena error ke stderr + guard if idx >= 0 melewati assert. Diperbaiki ke invocation umbrella valid yang benar-benar assert confidence — 3 vacuous jadi 3 real. Plus timeout=60 ke SEMUA subprocess di file itu, jadi hang (cf #303) gagal cepat, bukan 6 jam.

Verifikasi (dijalankan)

Ini agent-ergonomics: agent selalu bisa bedakan error vs empty dari stdout.

🤖 Generated with Claude Code

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

…oses #315)

An argparse error printed to stderr and left stdout empty, so an agent
parsing stdout saw "no results" instead of an error — the silent-wrong class
of #293/#300. A _StdoutErrorParser now emits {"s":"error",...} on stdout for
machine formats (json/compact/ai/sarif/...) while keeping the friendly stderr
message for humans.

Found by dogfooding: `search . --mode symbol execute` (the workspace-positional
form other umbrellas accept) returned zero bytes on stdout.

Exposed three vacuous tests in test_hybrid_engine: they invoked pre-#195 forms
(`impact X <ws>`, the dropped `dead-code <ws>`) that always errored, and passed
only because the error went to stderr and their `if idx >= 0` guard skipped the
assert. Fixed to valid post-#195 umbrella invocations that actually assert
confidence — three vacuous tests become three real ones. Added timeout=60 to
every subprocess in the file so a hang (cf #303) fails fast instead of running
to the 6h ceiling.

Verified: trap case now emits stdout JSON error; human mode unchanged; valid
calls unaffected; 4 new CLI-error tests; full suite 19 = 19 on main.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@sonarqubecloud

Copy link
Copy Markdown

@Wolfvin
Wolfvin merged commit 61c812b into main Jul 18, 2026
1 of 7 checks passed
@Wolfvin
Wolfvin deleted the fix/issue-315-cli-error-stdout branch July 18, 2026 02:12
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.

fix(cli): argparse errors go to stderr as bare text — agent parsing stdout JSON sees silent-empty (agent trap)

1 participant