{"record":{"id":"6f3c18875f71cfb5","repo":"zed-industries/zed","slug":"import-batches-is-only-supported-with-batching-cli","errorCode":null,"errorMessage":"Import batches is only supported with batching client","messagePattern":"Import batches is only supported with batching client","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/edit_prediction_cli/src/anthropic_client.rs","lineNumber":863,"sourceCode":"            AnthropicClient::Batch(batching_llm_client) => batching_llm_client.sync_batches().await,\n            AnthropicClient::Dummy => panic!(\"Dummy LLM client is not expected to be used\"),\n        }\n    }\n\n    pub fn pending_batch_count(&self) -> Result<usize> {\n        match self {\n            AnthropicClient::Plain(_) => Ok(0),\n            AnthropicClient::Batch(batching_llm_client) => {\n                batching_llm_client.pending_batch_count()\n            }\n            AnthropicClient::Dummy => panic!(\"Dummy LLM client is not expected to be used\"),\n        }\n    }\n\n    pub async fn import_batches(&self, batch_ids: &[String]) -> Result<()> {\n        match self {\n            AnthropicClient::Plain(_) => {\n                anyhow::bail!(\"Import batches is only supported with batching client\")\n            }\n            AnthropicClient::Batch(batching_llm_client) => {\n                batching_llm_client.import_batches(batch_ids).await\n            }\n            AnthropicClient::Dummy => panic!(\"Dummy LLM client is not expected to be used\"),\n        }\n    }\n}\n","sourceCodeStart":845,"sourceCodeEnd":872,"githubUrl":"https://github.com/zed-industries/zed/blob/f4178619acd0d47ea1f76a2025c42962c6d6638c/crates/edit_prediction_cli/src/anthropic_client.rs#L845-L872","documentation":"Thrown by AnthropicClient::import_batches when the client is the Plain (non-batching) variant. import_batches feeds externally-created Anthropic Batch API batch IDs into the client so pending results can be tracked and synced; a plain client has no batch machinery, so the operation is rejected. The symmetric sibling exists in the OpenAI client (error 227).","triggerScenarios":"Running a CLI command/flag that calls import_batches(batch_ids) (e.g. resuming a batch-idempotency workflow) while the Anthropic client was constructed as AnthropicClient::Plain — i.e. a non-batching provider was selected. Note pending_batch_count() on Plain just returns 0 instead of failing.","commonSituations":"Resuming a long teacher-data-generation run by passing previously issued batch IDs (--import-batches style flags) but forgetting to also enable the batching client; provider flag typos that silently fall back to the non-batching variant.","solutions":["Re-run with the batching provider/flag so the client is constructed as AnthropicClient::Batch","Check pending_batch_count() (returns 0 for Plain) before attempting import_batches","Verify the batch IDs belong to Anthropic's Batch API and you are not mixing them with the OpenAI client's IDs"],"exampleFix":"// before\nclient.import_batches(&batch_ids).await?; // Panics conceptually: Plain client\n\n// after\nif matches!(client, AnthropicClient::Batch(_)) {\n    client.import_batches(&batch_ids).await?;\n}","handlingStrategy":"type-guard","validationCode":"let can_import = matches!(client, AnthropicClient::Batch(_))\n    && client.pending_batch_count().map(|n| n >= 0).unwrap_or(false);","typeGuard":"fn is_batching(client: &AnthropicClient) -> bool {\n    matches!(client, AnthropicClient::Batch(_))\n}","tryCatchPattern":"if let Err(e) = client.import_batches(&batch_ids).await {\n    if e.to_string().contains(\"only supported with batching client\") {\n        log::warn!(\"skipping import: client is not in batching mode\");\n    } else {\n        return Err(e);\n    }\n}","preventionTips":["Only pass --import-batches style flags together with the batching provider selection","Use pending_batch_count() (returns 0 for Plain) as a cheap probe of batch mode before importing","Keep Anthropic and OpenAI batch IDs in separate variables/config keys so they never cross clients"],"tags":["rust","anthropic","batching","api-misuse"],"backgroundTag":"unsupported-operation","analyzedSha":"f4178619acd0d47ea1f76a2025c42962c6d6638c","analyzedAt":"2026-08-20T19:29:52.058Z","contentChangedAt":"2026-08-20T19:29:52.058Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}