[P2] base ensure and recreate accept --json but emit no JSON

#22 · closed · 1 comments

View on GitHub ↗

Azathothas

Tested the published **wsl-toolkit-v1.3.0 Windows amd64** binary on Windows 11/WSL2 on 2026-09-10. SHA-256: `71b2ef9b0cf50da0acda45e7cc9293185a2b18d8aa403812e20ed29222d54424`, matching the release manifest. Related: #6. ## Summary `base ensure --json` and `base recreate --json` accept the documented flag but emit no JSON object on stdout. They render the normal human state/progress on stderr and exit successfully, so an automation receives an empty structured answer. ## Reproduction Capture streams separately: ```powershell & $wtk base ensure --json & $wtk base recreate --json ``` Tested through the automatically selected helper and direct lifecycle path. For ensure, exit was 0, stdout was empty, and the state appeared only as human text on stderr. Recreate exhibits the same rendering path. `base status --json` works and emits valid structured output, making the behavior especially surprising. ## Cause `cmdBase` checks `asJSON` only in the `status` branches. Both helper and direct `ensure`/`recreate` branches unconditionally call `renderBaseState`. ## Expected Every subcommand that advertises/accepts `--json` should emit one nonempty documented JSON result on stdout and keep progress on stderr, or reject `--json` as inapplicable. Add assertions for nonempty parsable stdout on ensure and recreate, on both direct and helper routes.

Comments

Azathothas

Fixed in `wsl-toolkit-v2.0.0`, by `WSL-46` in `TODO/wsl-toolkit-go.md`. `base ensure` and `base recreate` emit one JSON document on stdout when asked for one. Re-derived against the published v2.0.0 binary, 2026-09-10: `wsl-toolkit base ensure --json` writes a parsable object and exits 0. The durable half is a guard rather than the fix. The acceptance suite now sweeps **every** surface that advertises `--json` and asserts each puts exactly one parsable document on stdout. It has already caught a second command with the same defect, written hours after this one was fixed, which is why the sweep exists rather than a case per command.