{"record":{"id":"52b6ed41372fd97e","repo":"openai/codex","slug":"request-failed-with-status-status-body","errorCode":null,"errorMessage":"Request failed with status {status}: {body}","messagePattern":"Request failed with status (.+?): (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"codex-rs/chatgpt/src/chatgpt_client.rs","lineNumber":115,"sourceCode":"        .headers(default_headers())\n        .headers(codex_model_provider::auth_provider_from_auth(&auth).to_auth_headers())\n        .header(OAI_PRODUCT_SKU_HEADER, CODEX_PRODUCT_SKU)\n        .header(\"Content-Type\", \"application/json\");\n    if let Some(timeout) = timeout {\n        request = request.timeout(timeout);\n    }\n    let response = request.send().await.context(\"Failed to send request\")?;\n\n    if response.status().is_success() {\n        let result: T = response\n            .json()\n            .await\n            .context(\"Failed to parse JSON response\")?;\n        Ok(result)\n    } else {\n        let status = response.status();\n        let body = response.text().await.unwrap_or_default();\n        anyhow::bail!(\"Request failed with status {status}: {body}\")\n    }\n}\n\n/// Make a POST request to the ChatGPT backend API with an already-captured auth identity.\n///\n/// Callers that bind other state to the auth snapshot should pass that same snapshot here rather\n/// than reacquiring auth while the request is in flight.\npub(crate) async fn chatgpt_post_request_with_timeout<\n    TResponse: DeserializeOwned,\n    TRequest: Serialize + ?Sized,\n>(\n    config: &Config,\n    auth: &CodexAuth,\n    path: String,\n    body: &TRequest,\n    timeout: Duration,\n    product_sku: &str,\n) -> anyhow::Result<TResponse> {","sourceCodeStart":97,"sourceCodeEnd":133,"githubUrl":"https://github.com/openai/codex/blob/339751715c64496cb86246bfb3935f40e309dd3d/codex-rs/chatgpt/src/chatgpt_client.rs#L97-L133","documentation":"Error \"Request failed with status {status}: {body}\" thrown in openai/codex.","triggerScenarios":"Thrown at codex-rs/chatgpt/src/chatgpt_client.rs:115 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"339751715c64496cb86246bfb3935f40e309dd3d","analyzedAt":"2026-08-25T05:35:09.876Z","schemaVersion":2},"datasetVersion":"2026-08-25T06:17:31.827Z"}