-
-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Description
While this shouldn't happen, if we make a mistake or if the user uses a CLI version that doesn't match the daemon version, it could be possible to get a HTTP 404 response from the daemon or some other HTTP error code.
Unfortunately the current CLI code doesn't handle this well, at least in one case, maybe in others, specifically:
(from
cascade/crates/cli/src/commands/zone.rs
Line 344 in 97145cd
| ZoneCommand::Status { zone, detailed } => { |
ZoneCommand::Status { zone, detailed } => {
let url = format!("zone/{}/status", zone);
let response: Result<ZoneStatus, ZoneStatusError> = client
.get(&url)
.send()
.and_then(|r| r.json())
.await
.map_err(|e| format!("HTTP request failed: {e:?}"))?;
This results in an error like so to the caller:
❯ target/debug/cascade --server 127.0.0.1:2006 zone status example.com
2026-02-27T09:23:11.069362Z ERROR cascade: Error: HTTP request failed: reqwest::Error { kind: Decode, source: Error("expected value", line: 1, column: 1) }
This is because .and_then(|r| r.json()) doesn't check the HTTP status code before attempting to parse the response as JSON. The error the user gets is a JSON parsing error, but actually there was a more fundamental problem that is hidden by the JSON parsing error.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels