Skip to content

fix(cli): return JSON envelopes for parser errors - #146

Draft
SaKaNa-Y wants to merge 1 commit into
x18n-dev:mainfrom
SaKaNa-Y:fix/cli-json-parser-errors
Draft

SaKaNa-Y wants to merge 1 commit into
x18n-dev:mainfrom
SaKaNa-Y:fix/cli-json-parser-errors

Conversation

@SaKaNa-Y

@SaKaNa-Y SaKaNa-Y commented Nov 5, 2026

Copy link
Copy Markdown

Summary

Scripts using --json expect a JSON response even when a command fails. An unknown option or missing argument instead leaves stdout empty and writes plain text to stderr, so the caller cannot read the error through the documented contract.

Use the parser's JSON option and matched command to return the existing error envelope. Keep exit code 2 and the current text output outside JSON mode.

 parameter validation fails
- write plain text to stderr
+ in JSON mode, write the error envelope to stdout
+ otherwise, write plain text to stderr
 exit with code 2

Evidence

  • Before: all four new JSON subprocess cases failed because stderr contained the error and stdout was empty.
  • After: all seven cases pass, covering unknown options, missing arguments, missing option values, the default command, text mode, --no-json, and literal arguments after --.
  • pnpm lint, pnpm knip, pnpm test --run (934 tests), pnpm typecheck, and pnpm build passed.

Merge Danger

Door: two-way

Blast Radius: CLI

The change affects parameter-validation failures in JSON mode. It preserves the existing envelope shape and exit code.

Parameter validation fails before command actions reach the JSON error handler. Use the parsed JSON option and matched command in the outer handler, preserving exit code 2 and text output outside JSON mode.
@vercel

vercel Bot commented Nov 5, 2026

Copy link
Copy Markdown

@SaKaNa-Y is attempting to deploy a commit to the NuxtLabs Team on Vercel.

A member of the Team first needs to authorize it.

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