zed-industries/zed · error

Failed to parse batch output: {:?}

Error message

Failed to parse batch output: {:?}

What it means

In import_batches for the edit prediction CLI: the OpenAI batch output file was downloaded successfully but its contents could not be parsed into per-item results. Indicates the output file format deviated from the expected JSONL batch result schema.

Source

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

            }

            let output_file_id = batch_status.output_file_id.ok_or_else(|| {
                anyhow::anyhow!("Batch {} completed but has no output file", batch_id)
            })?;

            let results_content = batches::download_file(
                self.http_client.as_ref(),
                OPEN_AI_API_URL,
                &self.api_key,
                &output_file_id,
            )
            .await
            .map_err(|e| {
                anyhow::anyhow!("Failed to download batch results for {}: {:?}", batch_id, e)
            })?;

            let results = batches::parse_batch_output(&results_content)
                .map_err(|e| anyhow::anyhow!("Failed to parse batch output: {:?}", e))?;

            let mut updates: Vec<(String, String, String)> = Vec::new();
            let mut success_count = 0;
            let mut error_count = 0;

            for result in results {
                let request_hash = result
                    .custom_id
                    .strip_prefix("req_hash_")
                    .unwrap_or(&result.custom_id)
                    .to_string();

                if let Some(response_body) = result.response {
                    if response_body.status_code == 200 {
                        let response_json = serde_json::to_string(&response_body.body)?;
                        updates.push((request_hash, response_json, batch_id.clone()));
                        success_count += 1;
                    } else {

View on GitHub (pinned to f4178619ac)

Solutions

  1. Inspect the wrapped serde error for the malformed field
  2. Re-download or re-generate the batch output
Defensive patterns

Strategy: try-catch

When it happens

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

Common situations: See trigger scenarios.

Understand the failure class


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