moghtech/komodo · error · anyhow::Error
{e:#?}
Error message
{e:#?} What it means
In the async post helper, after a successful HTTP status the client tries res.json(). If the response body cannot be deserialized into the expected type R, the anyhow error is formatted with {e:#?} and the HTTP status attached as context. So the request 'succeeded' at HTTP level but the payload didn't match the expected shape/type.
Solutions
- Compare the Debug dump in the message against the expected response struct; fix the mismatched field/type
- Check that client and Komodo server versions match and regenerate/update client types
- Verify the URL/endpoint and feature flags; hit the endpoint manually (curl) to inspect the raw body
- If status context shows a 2xx but body looks like an error, check middleware/proxies
Example fix
// before
let res: UpdateTargetResponse = client.read(ReadRequest::GetTarget { id })
.await?;
// after
match client.read::<serde_json::Value>(ReadRequest::GetTarget { id: target_id.clone() }).await {
Ok(v) => serde_json::from_value::<UpdateTargetResponse>(v)
.with_context(|| format!("unexpected response shape: {v}"))?,
Err(e) => return Err(e.context("GetTarget failed; inspect response shape")),
} Defensive patterns
Strategy: try-catch
Try / catch
match client.read(req).await {
Ok(res) => ...,
Err(e) if e.to_string().contains("Json(") || format!("{e:#}").contains("expected") => {
eprintln!("response shape mismatch: {e:#?}");
// inspect raw body / check client-server version
}
Err(e) => return Err(e),
} Prevention
- Pin client version to the Komodo server version
- Fetch into serde_json::Value first when response shapes are uncertain
- Curl new endpoints before wiring typed clients
When it happens
Trigger: API returns 2xx but body is not the expected JSON structure — wrong request path, API returning an error object inside a 200, or client struct R out of sync with server response type; also non-JSON bodies (HTML error pages) with 2xx.
Common situations: Komodo client/server version mismatch (types changed); calling read/write/execute/auth_login/auth_manage against a proxy that alters responses; typo'd request leading to an unexpected 2xx body.
Related errors
AI-assisted analysis of moghtech/komodo@780ac68b99 (2026-09-08).
Data as JSON: /api/errors/2ae388052c30991c.
Report an issue: GitHub.
Appendix: source
Thrown at client/core/rs/src/request.rs:221
>(
&self,
endpoint: &str,
body: B,
) -> anyhow::Result<R> {
let req = self
.reqwest
.post(format!("{}{endpoint}", self.address))
.header("x-api-key", &self.key)
.header("x-api-secret", &self.secret)
.header("content-type", "application/json")
.json(&body);
let res =
req.send().await.context("failed to reach Komodo API")?;
let status = res.status();
if status.is_success() {
match res.json().await {
Ok(res) => Ok(res),
Err(e) => Err(anyhow!("{e:#?}").context(status)),
}
} else {
match res.text().await {
Ok(res) => Err(deserialize_error(res).context(status)),
Err(e) => Err(anyhow!("{e:?}").context(status)),
}
}
}
#[cfg(feature = "blocking")]
fn post<B: Serialize + std::fmt::Debug, R: DeserializeOwned>(
&self,
endpoint: &str,
body: B,
) -> anyhow::Result<R> {
let req = self
.reqwest
.post(format!("{}{endpoint}", self.address))View on GitHub (pinned to 780ac68b99)