{"record":{"id":"b39154450b88aa1b","repo":"zed-industries/zed","slug":"import-batches-is-only-supported-with-batching-cli-b39154","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/openai_client.rs","lineNumber":700,"sourceCode":"        match self {\n            OpenAiClient::Plain(_) => Ok(()),\n            OpenAiClient::Batch(batching_client) => batching_client.sync_batches().await,\n            OpenAiClient::Dummy => panic!(\"Dummy OpenAI client is not expected to be used\"),\n        }\n    }\n\n    pub fn pending_batch_count(&self) -> Result<usize> {\n        match self {\n            OpenAiClient::Plain(_) => Ok(0),\n            OpenAiClient::Batch(batching_client) => batching_client.pending_batch_count(),\n            OpenAiClient::Dummy => panic!(\"Dummy OpenAI 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            OpenAiClient::Plain(_) => {\n                anyhow::bail!(\"Import batches is only supported with batching client\")\n            }\n            OpenAiClient::Batch(batching_client) => batching_client.import_batches(batch_ids).await,\n            OpenAiClient::Dummy => panic!(\"Dummy OpenAI client is not expected to be used\"),\n        }\n    }\n}\n","sourceCodeStart":682,"sourceCodeEnd":707,"githubUrl":"https://github.com/zed-industries/zed/blob/f4178619acd0d47ea1f76a2025c42962c6d6638c/crates/edit_prediction_cli/src/openai_client.rs#L682-L707","documentation":"OpenAI-side twin of error 222: OpenAiClient::import_batches rejects the call when the client is OpenAiClient::Plain. Importing externally-created OpenAI Batch API batch IDs only makes sense for the batching client, which tracks pending batches and syncs them; a plain request/response client has nothing to import into. pending_batch_count() on Plain returns Ok(0) instead of failing, so the failure surfaces only at import time.","triggerScenarios":"Invoking the import-batches flow (resuming a batch run by ID list) while the OpenAI teacher client was constructed in non-batching mode, e.g. provider teacher-non-batching:gpt54 combined with an --import-batches flag.","commonSituations":"Switching a gpt-teacher run between batching and non-batching providers mid-workflow and reusing the old batch IDs; CI scripts that always pass batch IDs but were flipped to a plain client.","solutions":["Run with the batching provider variant so the client is OpenAiClient::Batch","Gate the import call on the client variant (matches!(client, OpenAiClient::Batch(_)))","Confirm the batch IDs are OpenAI batch ids (batch_...) and not Anthropic ones — the two clients' import flows are not interchangeable"],"exampleFix":"// before\nopenai_client.import_batches(&batch_ids).await?; // Plain -> bail\n\n// after\nif matches!(openai_client, OpenAiClient::Batch(_)) {\n    openai_client.import_batches(&batch_ids).await?;\n}","handlingStrategy":"type-guard","validationCode":"let can_import = matches!(openai_client, OpenAiClient::Batch(_));","typeGuard":"fn is_batching(client: &OpenAiClient) -> bool {\n    matches!(client, OpenAiClient::Batch(_))\n}","tryCatchPattern":"if let Err(e) = openai_client.import_batches(&batch_ids).await {\n    if e.to_string().contains(\"only supported with batching client\") {\n        log::warn!(\"skipping import: OpenAI client is not in batching mode\");\n    } else {\n        return Err(e);\n    }\n}","preventionTips":["Enable the batching variant of the OpenAI client before any import-batches flow","Probe with pending_batch_count() — Plain returns Ok(0) without failing — to detect non-batching mode early","Never reuse Anthropic batch IDs with the OpenAI client or vice versa"],"tags":["rust","openai","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-14T05:17:10.506Z"}