oxidecomputer / oxidecomputer/oxide.rs

panic on bad JSON for `--json-body` argument

Open
#450 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
75
Forks
21
Avg merge
2d 2h
Merged PRs (30d)
19

Description

Following #449, I switched to /dev/stdin and found that the command still panics when it fails to parse JSON:

dap@ivanova ~ $ echo '{"source": { "url": "http://catacomb.eng.oxide.computer/media/cloud/debian-11-genericcloud-amd64.raw", block_size: 512 } }' | oxide image create --name my-image --description my-description --os debian --version 11 --json-body /dev/stdin
thread 'tokio-runtime-worker' panicked at 'called `Result::unwrap()` on an `Err` value: Error("key must be a string", line: 1, column: 104)', cli/src/generated_cli.rs:5801:84
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: JoinError::Panic(Id(17), ...)', cli/src/main.rs:59:10

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the command shown with malformed JSON, then inspect the JSON-body handling at cli/src/generated_cli.rs:5801 and the panic propagation at cli/src/main.rs:59. The fix is complete when invalid JSON produces an ordinary error instead of panicking through the CLI.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
50/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.