{"record":{"id":"7999cc2b953a5469","repo":"clockworklabs/SpacetimeDB","slug":"status-desc-status-from-url-url","errorCode":null,"errorMessage":"{status_desc} ({status}) from url ({url})","messagePattern":"(.+?) \\((.+?)\\) from url \\((.+?)\\)","errorType":"http","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/cli/src/util.rs","lineNumber":88,"sourceCode":"\nimpl ResponseExt for reqwest::Response {\n    async fn ensure_content_type(self, content_type: &str) -> anyhow::Result<Self> {\n        let status = self.status();\n        if self\n            .headers()\n            .get(http::header::CONTENT_TYPE)\n            .is_some_and(|ty| ty == content_type)\n        {\n            return Ok(self);\n        }\n        let url = self.url();\n        let Some(status_desc) = err_status_desc(status) else {\n            anyhow::bail!(\"HTTP response from url ({url}) was success but did not have content-type: {content_type}\");\n        };\n        let url = url.to_string();\n        let status_err = match self.error_for_status_ref() {\n            Err(e) => anyhow::Error::from(e),\n            Ok(_) => anyhow::anyhow!(\"{status_desc} ({status}) from url ({url})\"),\n        };\n        let err = match self.text().await {\n            Ok(text) => status_err.context(text),\n            Err(err) => anyhow::Error::from(err)\n                .context(format!(\"{status_desc} ({status})\"))\n                .context(\"failed to get response text\"),\n        };\n        Err(err)\n    }\n\n    async fn json_or_error<T: serde::de::DeserializeOwned>(self) -> anyhow::Result<T> {\n        let status = self.status();\n        self.ensure_content_type(\"application/json\")\n            .await?\n            .json()\n            .await\n            .map_err(|err| {\n                let mut err = anyhow::Error::from(err);","sourceCodeStart":70,"sourceCodeEnd":106,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/6dee26c6efc2856793e12b148a59742964f5d783/crates/cli/src/util.rs#L70-L106","documentation":"Raised by the CLI's HTTP response helper when a request to a SpacetimeDB endpoint returned an error status whose body is not the expected JSON content-type (e.g. an HTML error page), so the normal structured error decoding cannot apply. The message carries the status description, numeric code, URL, and the raw response text is attached as anyhow context.","triggerScenarios":"Any CLI HTTP call (publish, sql, login, fingerprint fetch...) that gets 4xx/5xx with a non-JSON body: pointing --url at a non-SpacetimeDB site or wrong port, reverse-proxy 502/503 HTML pages, Cloudflare-style challenges, 404s from wrong paths.","commonSituations":"Wrong server URL (website instead of the database server); server behind nginx/CDN returning HTML error pages; spacetimedb restarting or crashed while the proxy stays up; captive portals intercepting requests.","solutions":["Verify the server URL and port (`spacetime server list`), then probe with `curl -i <url>` to see the raw status and body the CLI is hitting","If a proxy fronts the server, fix its routing/timeouts so SpacetimeDB's JSON errors pass through unmangled","For 5xx during restarts, wait for the server (`spacetime server ping <name>`) and retry","Read the response text included in the error context — it usually names the real underlying problem (404 route, bad gateway, auth page)"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"# bash: confirm the endpoint speaks the expected API before running CLI commands\ncurl -fsS -o /dev/null -w '%{http_code} %{content_type}\\n' \"$URL/database\" || echo \"endpoint unhealthy or not SpacetimeDB\"","typeGuard":null,"tryCatchPattern":"// Inspect status + content-type and branch: retry 5xx transient, surface 4xx body\nmatch resp.error_for_status() {\n    Ok(r) if r.headers().get(CONTENT_TYPE).map_or(false, |v| v.starts_with(\"application/json\")) => parse_json(r),\n    Err(e) if e.status().map_or(false, |s| s.is_server_error()) => retry_with_backoff(),\n    Err(e) => surf_non_json_body(e).await, // log body text for diagnosis\n}","preventionTips":["Health-check server URLs (curl -i) when adding them: `spacetime server add` fetches a fingerprint and fails early on wrong endpoints","Keep proxies from rewriting SpacetimeDB error responses into HTML pages","Treat non-JSON error bodies as configuration/routing problems first, not as SDK bugs"],"tags":["http","network","cli","response-handling"],"backgroundTag":"http-error-response","analyzedSha":"6dee26c6efc2856793e12b148a59742964f5d783","analyzedAt":"2026-08-20T06:08:37.179Z","contentChangedAt":"2026-08-20T06:08:37.179Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}