Repository navigation
fix(cli): flatten repeatable JSON array flags and gate Sentinel CommandError reporting - #101
Merged
Merged
Conversation
…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]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes three issues identified from today's Sentinel alert triage:
/v1/git/repos/{name}/push400invalid body: json...):field_valueinsrc/commands/product/mod.rswrapped a JSON array passed to a repeatableTy::Json/Ty::Unionflag (such ashanzo git repos push <repo> --files '[{path:...}]') in an extra array ([[{path:...}]]), causing Go'sjson.Unmarshalto reject it with HTTP 400.genproduct.rsclassifies nested arrays withrepeat: false, anyrepeat: trueJSON flag represents a flat 1D schema array. Top-levelValue::Arrayarguments are now flattened so both--files '[{...},{...}]'and repeated--files '{...}' --files '{...}'serialize identically.CommandErrorcrashes to Sentinel:launch::ChildExited(used bylaunch::execandk8s::cmd_restart) andproduct::HttpStatusError(used byproduct::call,accepted_session,follow_session, andchannels).telemetry::should_capture_errorso 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 clientCommandErrorexceptions. Failed runs still recordok: falseoncommand_completed.telemetry::install_panic_hookwrapsinstall_broken_pipe_quiet; skip emitting aPanicevent on broken pipe before delegating toprev(info).Verification
cargo test: all 512 tests pass (466 unit + 46 integration, including 5 new tests coveringgit repos push --filesarray/repeated serialization andshould_capture_error).