Skip to content

fix(cli): flatten repeatable JSON array flags and gate Sentinel CommandError reporting - #101

Merged
zooqueen merged 1 commit into
mainfrom
fix/cli-error-reporting
Nov 26, 2026
Merged

zooqueen merged 1 commit into
mainfrom
fix/cli-error-reporting

Conversation

@zooqueen

Copy link
Copy Markdown
Member

Summary

Fixes three issues identified from today's Sentinel alert triage:

  1. Repeatable JSON array serialization bug (/v1/git/repos/{name}/push 400 invalid body: json...):
    • field_value in src/commands/product/mod.rs wrapped a JSON array passed to a repeatable Ty::Json/Ty::Union flag (such as hanzo git repos push <repo> --files '[{path:...}]') in an extra array ([[{path:...}]]), causing Go's json.Unmarshal to reject it with HTTP 400.
    • Because genproduct.rs classifies nested arrays with repeat: false, any repeat: true JSON flag represents a flat 1D schema array. Top-level Value::Array arguments are now flattened so both --files '[{...},{...}]' and repeated --files '{...}' --files '{...}' serialize identically.
  2. Stop reporting child exits and API HTTP status refusals as CommandError crashes to Sentinel:
    • Added typed launch::ChildExited (used by launch::exec and k8s::cmd_restart) and product::HttpStatusError (used by product::call, accepted_session, follow_session, and channels).
    • Added telemetry::should_capture_error so child process non-zero exits (e.g. kubectl exited with exit status: 1) and server HTTP status responses (4xx user/auth/validation refusals and 5xx upstream faults already alerted server-side) are not filed as client CommandError exceptions. Failed runs still record ok: false on command_completed.
  3. Broken-pipe panic hook ordering:
    • telemetry::install_panic_hook wraps install_broken_pipe_quiet; skip emitting a Panic event on broken pipe before delegating to prev(info).

Verification

  • cargo test: all 512 tests pass (466 unit + 46 integration, including 5 new tests covering git repos push --files array/repeated serialization and should_capture_error).

…xits / API status refusals as CommandError

Fixes three CLI issues surfaced in Sentinel alert triage:

1. Repeatable JSON flags (e.g. `hanzo git repos push <repo> --files '[{...}]'`):
   `field_value` previously wrapped a JSON array passed to a repeatable `Ty::Json`
   flag into a nested array (`[[{...}]]`), causing server `json.Unmarshal` 400
   failures (`invalid body: json: cannot unmarshal array into Go struct field`).
   Top-level `Value::Array` values are now flattened (nested arrays have
   `repeat: false` in `genproduct.rs`), so both `--files '[{...},{...}]'` and
   repeated `--files '{...}' --files '{...}'` produce the expected flat array.

2. Sentinel `CommandError` noise:
   - `launch::exec` (used by `hanzo k8s` / `kubectl`, `helm`, `hanzo-vm`,
     `buildctl`, etc.) and `k8s::cmd_restart` now return typed `ChildExited`.
   - `product::call`, `accepted_session`, `follow_session`, and `channels` now
     return typed `HttpStatusError` for non-2xx API responses.
   - `telemetry::should_capture_error` skips filing `ChildExited` and
     `HttpStatusError` (4xx user/auth/validation refusals and 5xx upstream faults
     already tracked server-side) as `CommandError` crashes, while `command_completed`
     still records `ok: false`.

3. Broken-pipe panic hook ordering:
   `telemetry::install_panic_hook` now skips emitting a `Panic` event when
   `is_broken_pipe` matches before delegating to the quiet broken-pipe hook.

Co-authored-by: Hanzo Dev <[email protected]>
@zooqueen
zooqueen merged commit 7b746b7 into main Nov 26, 2026
1 check passed
@zooqueen
zooqueen deleted the fix/cli-error-reporting branch November 26, 2026 21:36
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