zed-industries/zed · error

Failed to create batch

Error message

Failed to create batch: {:?}

What it means

upload_pending_requests creates the OpenAI batch from the uploaded file; this error wraps a failed create_batch call, meaning the batch job itself could not be registered even though the file uploaded successfully.

Solutions

  1. Check the wrapped error for quota or parameter causes
  2. Retry batch creation after resolving the failure
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at crates/edit_prediction_cli/src/openai_client.rs:546 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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

Appendix: source

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

            let filename = format!("batch_{}.jsonl", chrono::Utc::now().timestamp());
            let file_obj = batches::upload_batch_file(
                self.http_client.as_ref(),
                OPEN_AI_API_URL,
                &self.api_key,
                &filename,
                jsonl_content.into_bytes(),
            )
            .await
            .map_err(|e| anyhow::anyhow!("Failed to upload batch file: {:?}", e))?;

            let batch = batches::create_batch(
                self.http_client.as_ref(),
                OPEN_AI_API_URL,
                &self.api_key,
                batches::CreateBatchRequest::new(file_obj.id),
            )
            .await
            .map_err(|e| anyhow::anyhow!("Failed to create batch: {:?}", e))?;

            {
                let connection = self.connection.lock().unwrap();
                connection.with_savepoint("batch_upload", || {
                    let q = sql!(UPDATE openai_cache SET batch_id = ? WHERE request_hash = ?);
                    let mut exec = connection.exec_bound::<(&str, &str)>(q)?;
                    for hash in &request_hashes {
                        exec((batch.id.as_str(), hash.as_str()))?;
                    }
                    Ok(())
                })?;
            }

            let batch_len = rows.len();
            total_uploaded += batch_len;
            log::info!(
                "Uploaded batch {} with {} requests ({} total)",
                batch.id,

View on GitHub (pinned to f4178619ac)