{"record":{"id":"ffbc04fcc99e6e53","repo":"openai/codex","slug":"thread-usage-response-did-not-contain-requested-th","errorCode":null,"errorMessage":"thread usage response did not contain requested thread {thread_id}","messagePattern":"thread usage response did not contain requested thread (.+?)","errorType":"exception","errorClass":"RequestError","httpStatus":null,"severity":"error","filePath":"codex-rs/backend-client/src/client/thread_usage.rs","lineNumber":68,"sourceCode":"        let url = self.thread_usage_url();\n        let request = self\n            .request(Method::POST, &url)\n            .headers(self.headers())\n            .header(CONTENT_TYPE, HeaderValue::from_static(\"application/json\"))\n            .json(&ThreadUsageQueryRequest {\n                thread_ids: [thread_id],\n            });\n        let (body, content_type) = self.exec_request_detailed(request, \"POST\", &url).await?;\n        let response = self\n            .decode_json::<ThreadUsageQueryResponse>(&url, &content_type, &body)\n            .map_err(RequestError::from)?;\n\n        response\n            .threads\n            .into_iter()\n            .find(|usage| usage.thread_id == thread_id)\n            .ok_or_else(|| {\n                RequestError::from(anyhow!(\n                    \"thread usage response did not contain requested thread {thread_id}\"\n                ))\n            })\n    }\n\n    fn thread_usage_url(&self) -> String {\n        match self.path_style {\n            PathStyle::CodexApi => {\n                format!(\"{}/api/codex/usage/thread_usage/query\", self.base_url)\n            }\n            PathStyle::ChatGptApi => {\n                format!(\"{}/wham/usage/thread_usage/query\", self.base_url)\n            }\n        }\n    }\n}\n\n#[cfg(test)]","sourceCodeStart":50,"sourceCodeEnd":86,"githubUrl":"https://github.com/openai/codex/blob/339751715c64496cb86246bfb3935f40e309dd3d/codex-rs/backend-client/src/client/thread_usage.rs#L50-L86","documentation":"Consistency error in get_thread_usage: the backend answered the usage query successfully, but the returned totals contain no entry for the thread id that was requested (e.g. the thread was pruned or the response is for different threads). Rather than attributing another thread's usage, the accessor fails with the requested thread id in the message.","triggerScenarios":"Thrown at codex-rs/backend-client/src/client/thread_usage.rs:68 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify the thread id exists and was created on the same backend/account","Treat the thread as having no usage data and handle the missing-entry case explicitly instead of retrying blindly"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"339751715c64496cb86246bfb3935f40e309dd3d","analyzedAt":"2026-08-25T05:35:09.876Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}