{"record":{"id":"b0e17637d0f3ac41","repo":"databendlabs/databend","slug":"status-code-status-msg-msg","errorCode":null,"errorMessage":"status code: {status}, msg: {msg}","messagePattern":"status code: (.+?), msg: (.+?)","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/meta/control/src/admin.rs","lineNumber":49,"sourceCode":"            endpoint: format!(\"http://{}\", addr),\n        }\n    }\n\n    /// Send a GET request and return the response on success,\n    /// or an error containing the status code and response body on failure.\n    async fn checked_get(&self, path: &str) -> anyhow::Result<reqwest::Response> {\n        let resp = self\n            .client\n            .get(format!(\"{}{path}\", self.endpoint))\n            .send()\n            .await?;\n        let status = resp.status();\n        if status.is_success() {\n            Ok(resp)\n        } else {\n            let data = resp.bytes().await?;\n            let msg = String::from_utf8_lossy(&data);\n            Err(anyhow::anyhow!(\"status code: {status}, msg: {msg}\"))\n        }\n    }\n\n    /// Send a GET request and deserialize the JSON response.\n    async fn get_json<T: DeserializeOwned>(&self, path: &str) -> anyhow::Result<T> {\n        let resp = self.checked_get(path).await?;\n        Ok(resp.json().await?)\n    }\n\n    pub async fn status(&self) -> anyhow::Result<AdminStatusResponse> {\n        self.get_json(\"/v1/cluster/status\").await\n    }\n\n    /// Transfer raft leadership to the specified node, or to a random voter if `target` is `None`.\n    pub async fn transfer_leader(\n        &self,\n        target: Option<u64>,\n    ) -> anyhow::Result<AdminTransferLeaderResponse> {","sourceCodeStart":31,"sourceCodeEnd":67,"githubUrl":"https://github.com/databendlabs/databend/blob/288d84d76e20a2f8f7173bda9691eb6ece301aa9/src/meta/control/src/admin.rs#L31-L67","documentation":"The meta control (metabench/metactl) HTTP client has a checked_get helper that treats any non-2xx admin API response as an error, embedding the HTTP status code and the response body message: 'status code: {status}, msg: {msg}'.","triggerScenarios":"checked_get is called (directly or via get_json/trigger_snapshot/get_metrics) and the admin API returns 4xx/5xx, e.g. wrong endpoint path, node unavailable behind a proxy, or API rejecting the request.","commonSituations":"Hitting a metasrv whose admin API is not enabled; wrong port routing to another service; server-side errors while triggering snapshots or reading metrics; proxy returning 502/503.","solutions":["Check the status code and msg in the error to identify the server-side cause","Verify the admin API address and path are correct for the running metasrv version","Ensure no proxy is intercepting and returning gateway errors"],"exampleFix":"// before\nmetactl ... --admin-api-address http://localhost:8080  # wrong service\n// after\nmetactl ... --admin-api-address http://localhost:28102  # metasrv admin api","handlingStrategy":"try-catch","validationCode":"let resp = reqwest::get(url).await?;\nif !resp.status().is_success() {\n    eprintln!(\"admin api returned {}\", resp.status());\n}","typeGuard":null,"tryCatchPattern":"match client.checked_get(path).await {\n    Ok(resp) => handle(resp),\n    Err(e) => eprintln!(\"admin request failed ({}); check status/msg embedded in error\", e),\n}","preventionTips":["Parse the embedded status code and msg to categorize 4xx vs 5xx","Keep metactl paths in sync with the metasrv API version","Bypass error-prone proxy layers for admin endpoints"],"tags":["http","admin-api","error-handling"],"backgroundTag":"http-non-2xx-response","analyzedSha":"288d84d76e20a2f8f7173bda9691eb6ece301aa9","analyzedAt":"2026-09-11T11:29:36.208Z","contentChangedAt":"2026-09-11T11:29:36.208Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}