Skip to content

Daemon HTTP 404 errors result in confusing CLI errors. #481

@ximon18

Description

@ximon18

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

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.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions