zed-industries/zed · error

Import batches is only supported with batching client

Error message

Import batches is only supported with batching client

What it means

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.

Source

Thrown at crates/edit_prediction_cli/src/openai_client.rs:700

        match self {
            OpenAiClient::Plain(_) => Ok(()),
            OpenAiClient::Batch(batching_client) => batching_client.sync_batches().await,
            OpenAiClient::Dummy => panic!("Dummy OpenAI client is not expected to be used"),
        }
    }

    pub fn pending_batch_count(&self) -> Result<usize> {
        match self {
            OpenAiClient::Plain(_) => Ok(0),
            OpenAiClient::Batch(batching_client) => batching_client.pending_batch_count(),
            OpenAiClient::Dummy => panic!("Dummy OpenAI client is not expected to be used"),
        }
    }

    pub async fn import_batches(&self, batch_ids: &[String]) -> Result<()> {
        match self {
            OpenAiClient::Plain(_) => {
                anyhow::bail!("Import batches is only supported with batching client")
            }
            OpenAiClient::Batch(batching_client) => batching_client.import_batches(batch_ids).await,
            OpenAiClient::Dummy => panic!("Dummy OpenAI client is not expected to be used"),
        }
    }
}

View on GitHub (pinned to f4178619ac)

Solutions

  1. Run with the batching provider variant so the client is OpenAiClient::Batch
  2. Gate the import call on the client variant (matches!(client, OpenAiClient::Batch(_)))
  3. Confirm the batch IDs are OpenAI batch ids (batch_...) and not Anthropic ones — the two clients' import flows are not interchangeable

Example fix

// before
openai_client.import_batches(&batch_ids).await?; // Plain -> bail

// after
if matches!(openai_client, OpenAiClient::Batch(_)) {
    openai_client.import_batches(&batch_ids).await?;
}
Defensive patterns

Strategy: type-guard

Validate before calling

let can_import = matches!(openai_client, OpenAiClient::Batch(_));

Type guard

fn is_batching(client: &OpenAiClient) -> bool {
    matches!(client, OpenAiClient::Batch(_))
}

Try / catch

if let Err(e) = openai_client.import_batches(&batch_ids).await {
    if e.to_string().contains("only supported with batching client") {
        log::warn!("skipping import: OpenAI client is not in batching mode");
    } else {
        return Err(e);
    }
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


AI-assisted analysis of zed-industries/zed@f4178619ac (2026-08-20). Data as JSON: /api/errors/b39154450b88aa1b. Report an issue: GitHub.