Skip to content

fix(cli): honour -f json on the error envelope - #368

Merged
ankitranjan7 merged 1 commit into
mainfrom
fix/error-envelope-format
Aug 19, 2026
Merged

fix(cli): honour -f json on the error envelope#368
ankitranjan7 merged 1 commit into
mainfrom
fix/error-envelope-format

Conversation

@ankitranjan7

Copy link
Copy Markdown
Contributor

webcmd … -f json still printed YAML error envelopes. An agent that JSON.parses stderr died on every built-in or adapter failure.

After

$ webcmd validate nope -f json
# stderr, exit 2
{
  "ok": false,
  "error": {
    "code": "ARGUMENT",
    "message": "No command matches \"nope\". …",
    "exitCode": 2
  }
}
  • -f json → JSON envelope on stderr
  • every other format, and no -f, → existing YAML envelope
  • AutoFix # comments are YAML-only so JSON stays parseable
  • Same path for local built-ins (reportCliError), adapter commands, and hosted typed errors

Hosted impact

Hosted impact: B — rides the pin bump
Trigger: none
Why: CLI presentation only (`formatErrorEnvelope`). Cloud already returns JSON `{ok:false,error}` over HTTP; no cloud code or contract change.
Sequencing: none. Behaviour reaches hosted CLI users at the next bump:webcmd.

Verification

  • npx tsc --noEmit — clean
  • npx vitest run --project unit src/output.test.ts src/cli-error-report.test.ts src/commanderAdapter.test.ts src/hosted/runner.test.ts — 180 passed

Built-in and adapter failures still go to stderr, but a requested JSON
format is no longer dumped as YAML. Other formats keep the YAML envelope.
@github-actions

Copy link
Copy Markdown
Contributor

🟠 Maintainer review suggested — low confidence

The automated review could not reach a fully supported conclusion.

This review is advisory and does not block merging.

@ankitranjan7
ankitranjan7 merged commit bc102a9 into main Aug 19, 2026
37 checks passed
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