{"record":{"id":"3df54cbe46d84a4d","repo":"zed-industries/zed","slug":"failed-to-create-anthropic-client-3df54c","errorCode":null,"errorMessage":"Failed to create Anthropic client","messagePattern":"Failed to create Anthropic client","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/edit_prediction_cli/src/qa.rs","lineNumber":194,"sourceCode":"\n    run_parse_output(example).context(\"Failed to execute run_parse_output\")?;\n\n    if example.prompt_inputs.is_none() {\n        anyhow::bail!(\"prompt_inputs missing (run context retrieval first)\");\n    }\n\n    let step_progress = example_progress.start(Step::Qa);\n\n    let model = model_for_backend(args.backend);\n    let prompt = build_prompt(example).context(\"Failed to build QA prompt\")?;\n\n    step_progress.set_substatus(\"generating\");\n\n    let response = match args.backend {\n        BatchProvider::Anthropic => {\n            let client = if args.no_batch {\n                ANTHROPIC_CLIENT_PLAIN.get_or_init(|| {\n                    AnthropicClient::plain().expect(\"Failed to create Anthropic client\")\n                })\n            } else {\n                ANTHROPIC_CLIENT_BATCH.get_or_init(|| {\n                    AnthropicClient::batch(&LLM_CACHE_DB)\n                        .expect(\"Failed to create Anthropic client\")\n                })\n            };\n\n            let messages = vec![anthropic::Message {\n                role: anthropic::Role::User,\n                content: vec![anthropic::RequestContent::Text {\n                    text: prompt,\n                    cache_control: None,\n                }],\n            }];\n\n            let Some(response) = client.generate(model, 1024, messages, None, false).await? else {\n                return Ok(());","sourceCodeStart":176,"sourceCodeEnd":212,"githubUrl":"https://github.com/zed-industries/zed/blob/f4178619acd0d47ea1f76a2025c42962c6d6638c/crates/edit_prediction_cli/src/qa.rs#L176-L212","documentation":"Panics inside run_qa when the AnthropicClient constructor fails while setting up the QA client (ANTHROPIC_CLIENT_PLAIN or the batched variant backed by LLM_CACHE_DB). The constructor error — typically inability to open or create the LLM cache database — is swallowed by expect on first QA generation, aborting the whole run instead of surfacing as the anyhow error run_qa already returns for its other steps.","triggerScenarios":"Thrown at crates/edit_prediction_cli/src/qa.rs:194 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Make the QA client initialization fallible and return Err from run_qa with the constructor's error attached","Surface the cache DB path so the user can fix or remove it","Initialize required clients once at CLI startup and fail fast with a clear message"],"exampleFix":null,"handlingStrategy":"try-catch","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"}