{"record":{"id":"abced21d55089759","repo":"zed-industries/zed","slug":"failed-to-create-openai-client-abced2","errorCode":null,"errorMessage":"Failed to create OpenAI client","messagePattern":"Failed to create OpenAI client","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/edit_prediction_cli/src/repair.rs","lineNumber":375,"sourceCode":"\n            let Some(response) = client.generate(model, 16384, messages, None, false).await? else {\n                return Ok(());\n            };\n\n            response\n                .content\n                .iter()\n                .filter_map(|c| match c {\n                    anthropic::ResponseContent::Text { text } => Some(text.as_str()),\n                    _ => None,\n                })\n                .collect::<Vec<_>>()\n                .concat()\n        }\n        BatchProvider::Openai => {\n            let client = if args.no_batch {\n                OPENAI_CLIENT_PLAIN\n                    .get_or_init(|| OpenAiClient::plain().expect(\"Failed to create OpenAI client\"))\n            } else {\n                OPENAI_CLIENT_BATCH.get_or_init(|| {\n                    OpenAiClient::batch(&LLM_CACHE_DB).expect(\"Failed to create OpenAI client\")\n                })\n            };\n\n            let messages = vec![\n                // Turn 1: Original teacher prompt\n                open_ai::RequestMessage::User {\n                    content: open_ai::MessageContent::Plain(teacher_prompt.input.clone()),\n                },\n                // Turn 2: Original teacher response\n                open_ai::RequestMessage::Assistant {\n                    content: Some(open_ai::MessageContent::Plain(teacher_response.clone())),\n                    tool_calls: vec![],\n                    reasoning_content: None,\n                    reasoning_details: None,\n                },","sourceCodeStart":357,"sourceCodeEnd":393,"githubUrl":"https://github.com/zed-industries/zed/blob/f4178619acd0d47ea1f76a2025c42962c6d6638c/crates/edit_prediction_cli/src/repair.rs#L357-L393","documentation":"Panics inside run_repair's Openai arm when the OpenAiClient constructor fails for the repair step (plain or batched against LLM_CACHE_DB). During batch reprocessing the shared cache database is under concurrent access, so a constructor error from a locked or busy cache DB is turned into a panic by expect rather than a per-example error the driver can record and continue past.","triggerScenarios":"Thrown at crates/edit_prediction_cli/src/repair.rs:375 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Return the constructor error from run_repair via ? so reprocess_after_batch_wait can mark just this example failed","Add retry-with-backoff around client construction to ride out transient cache DB contention","Fail fast on client construction once at startup to avoid mid-run aborts"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"f4178619acd0d47ea1f76a2025c42962c6d6638c","analyzedAt":"2026-08-20T19:29:52.058Z","contentChangedAt":"2026-08-20T19:29:52.058Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}