{"record":{"id":"40963bb80ce554ab","repo":"Pumpkin-MC/Pumpkin","slug":"http-response-returned-error-status-0-1","errorCode":null,"errorMessage":"HTTP response returned error status {0}: {1}","messagePattern":"HTTP response returned error status (.+?): (.+?)","errorType":"exception","errorClass":"HttpError","httpStatus":null,"severity":"error","filePath":"crates/pumpkin-plugin-utils/src/http.rs","lineNumber":12,"sourceCode":"//! HTTP client helpers for online license checks and marketplace queries.\n\nuse thiserror::Error;\n\n/// HTTP request errors.\n#[derive(Debug, Error)]\npub enum HttpError {\n    /// Network or connection error.\n    #[error(\"HTTP request failed: {0}\")]\n    RequestFailed(String),\n    /// Response status code was not successful (2xx).\n    #[error(\"HTTP response returned error status {0}: {1}\")]\n    BadStatus(u16, String),\n    /// Error reading response body.\n    #[error(\"Failed to read HTTP response body: {0}\")]\n    BodyRead(String),\n}\n\n/// Helper client for querying Pumpkin marketplace REST APIs.\npub struct HttpClient {\n    client: reqwest::blocking::Client,\n}\n\nimpl Default for HttpClient {\n    fn default() -> Self {\n        Self::new(\"Pumpkin-Plugin-Utils/0.1.0\")\n    }\n}\n\nimpl HttpClient {","sourceCodeStart":1,"sourceCodeEnd":30,"githubUrl":"https://github.com/Pumpkin-MC/Pumpkin/blob/8d4639e25a57c15e47448ec327c780d41bbf2356/crates/pumpkin-plugin-utils/src/http.rs#L1-L30","documentation":"`HttpError::BadStatus` is returned when an HTTP response completed but its status code was not successful (not 2xx); it displays as \"HTTP response returned error status {0}: {1}\" carrying the numeric status and the response/status text. It lets plugin code distinguish server-side rejections (404, 401, 500, rate limits) from transport failures (`RequestFailed`).","triggerScenarios":"Any HTTP utility call in pumpkin-plugin-utils that receives a response with a non-2xx status — e.g. requesting a deleted resource (404), expired/missing credentials (401/403), server errors (5xx), or hitting a rate limit (429).","commonSituations":"Outdated API endpoints in plugin config; missing or expired API keys; calling an API too frequently and getting 429; upstream service outage returning 5xx; typo in the URL path.","solutions":["Inspect the status code and message: handle 401/403 by fixing credentials, 404 by correcting the URL, 429 by backing off.","Add retry-with-backoff only for 5xx/429; do not retry 4xx client errors.","Validate configured endpoints and auth material before requests.","Match on `HttpError::BadStatus(status, msg)` to branch on the status code programmatically."],"exampleFix":"// before\nlet data = http::get(&url).unwrap();\n// after\nmatch http::get(&url) {\n    Ok(data) => {},\n    Err(HttpError::BadStatus(429, _)) => schedule_retry(),\n    Err(HttpError::BadStatus(code, msg)) => log::error!(\"API rejected: {code} {msg}\"),\n    Err(e) => log::error!(\"{e}\"),\n}","handlingStrategy":"try-catch","validationCode":"// Validate auth and endpoint before calling:\nassert!(!api_key.is_empty(), \"missing API key for remote endpoint\");","typeGuard":"fn is_bad_status(e: &HttpError) -> Option<(u16, &str)> {\n    match e { HttpError::BadStatus(c, m) => Some((*c, m.as_str())), _ => None }\n}","tryCatchPattern":"match http::get(&url) {\n    Ok(data) => process(data),\n    Err(HttpError::BadStatus(code, msg)) if code == 429 || code >= 500 => retry_with_backoff(),\n    Err(HttpError::BadStatus(code, msg)) => log::error!(\"request rejected: {code} {msg}\"),\n    Err(e) => log::error!(\"{e}\"),\n}","preventionTips":["Branch retry policy on the status code: back off on 429/5xx only.","Refresh API keys before expiry and handle 401/403 explicitly.","Keep API endpoint paths in config validated at startup.","Match HttpError variants instead of treating all HTTP failures alike."],"tags":["http","status-code","api","plugin-utils"],"backgroundTag":"http-error-status","analyzedSha":"8d4639e25a57c15e47448ec327c780d41bbf2356","analyzedAt":"2026-09-09T15:32:22.916Z","contentChangedAt":"2026-09-09T15:32:22.916Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}