Skip to content

fix(quickstart): route invalid --concurrency warning to stderr in --json mode - #204

Merged
ethanj merged 1 commit into
mainfrom
fix/quickstart-json-stdout-warning
Sep 1, 2026
Merged

fix(quickstart): route invalid --concurrency warning to stderr in --json mode#204
ethanj merged 1 commit into
mainfrom
fix/quickstart-json-stdout-warning

Conversation

@ethanj

@ethanj ethanj commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Closes #191.

What

In --json mode, an invalid --concurrency value (eight, 0, 2.5, -1) emitted a
yellow ANSI warning on stdout before the JSON envelope while still exiting 0 — silently
unparseable output for any automated caller.

Root cause: the warning fires while Commander constructs quickstartCommand's arguments —
argument expressions evaluate before the callee body, so setQuiet(jsonMode) inside
quickstartCommand can never intercept it. The channel has to be chosen at the call site.

How

parseConcurrencyFlag gains an explicit diagnostic target (default stdout):

  • quickstart --json routes the warning to stderr — visible to the operator, stdout
    stays a single parseable envelope.
  • Human mode (and compile/refresh/watch, which have no --json) keeps today's stdout
    warning byte-for-byte.
  • Invalid input still returns undefined, so the env-var/default fallback and the exit
    code are unchanged. Suppressing the warning outright was rejected — the diagnostic must
    remain visible.

Tests

New end-to-end test drives the built CLI:

  • --json, parameterized over all four rejection shapes (eight, 0, 2.5, -1):
    exit 0, stdout parses as one envelope with exactly its existing keys (no new diagnostic
    field), stdout free of the warning, stderr carries the byte-exact warning.
  • Human mode: the unchanged yellow warning bytes on stdout, stderr clean.
  • Hermetic env: provider credentials and LLMWIKI_COMPILE_CONCURRENCY blanked so ambient
    environment cannot perturb the fallback under test.

Full suite: 671 files, 5,033 tests passing.

Docs

Updated the --json flag row (docs/cli/ingest.mdx) and the invalid-flag note in
docs/configuration/environment-variables.mdx.

Note: #201 addresses the same issue with an equivalent stderr routing; this PR additionally
covers all four rejection shapes, pins the envelope shape, preserves the human-mode warning
bytes exactly, and updates the docs — one of the two should close #191.

…son mode

Invalid --concurrency parsing emitted through stdout while quickstart's
options were being constructed, before quickstartCommand could enable JSON
quiet mode: argument expressions evaluate before the callee body runs, so
setQuiet(jsonMode) can never intercept this warning, and `quickstart --json
--concurrency eight` produced a yellow ANSI line ahead of the JSON envelope
while still exiting 0 — silently unparseable output for automated callers.

parseConcurrencyFlag now accepts an explicit diagnostic target: human
compile, refresh, watch, and quickstart calls retain stdout byte-for-byte,
while quickstart --json routes the warning to stderr so it stays visible to
the operator without contaminating the envelope. The parser still returns
undefined on invalid input, so the environment-variable and default
concurrency fallback is unchanged, and the command still exits 0.
Suppressing the warning outright was rejected: the diagnostic must remain
visible.

The new end-to-end test drives the built CLI in both modes: in --json mode
it is parameterized over all four rejection shapes ("eight", "0", "2.5",
"-1") and asserts exit 0, a single parseable envelope with exactly its
existing keys, a warning-free stdout, and the byte-exact warning on stderr;
in human mode it asserts the unchanged yellow warning bytes on stdout and a
clean stderr. Docs updated for the --json flag row and the
LLMWIKI_COMPILE_CONCURRENCY invalid-flag note.

Closes #191
@ethanj
ethanj merged commit cb4ff80 into main Sep 1, 2026
3 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.

quickstart --json writes a warning to stdout before the JSON envelope on invalid --concurrency

1 participant