zed-industries/zed · error
No diff blocks found in section {}
Error message
No diff blocks found in section {} What it means
Bailed by extract_diff_block when the named section (e.g. EDIT_HISTORY: or EXPECTED_PATCH:) exists in the response but no fenced code block with diff content could be extracted from its body. This differs from a missing section: the heading was found, yet the scanner located no ``` fenced block, so the hunks list stayed empty.
Source
Thrown at crates/edit_prediction_cli/src/synthesize.rs:658
.find('\n')
.map(|i| abs_diff_start + i + 1)
.unwrap_or(abs_diff_start);
if let Some(block_end_rel) = section_content[block_content_start..].find("```") {
let block_end = block_content_start + block_end_rel;
let diff_content = section_content[block_content_start..block_end].trim();
// Split this block into hunks (in case multiple hunks in one block)
hunks.extend(split_into_hunks(diff_content));
search_start = block_end + 3;
} else {
break;
}
}
if hunks.is_empty() {
anyhow::bail!("No diff blocks found in section {}", section_marker);
}
Ok(hunks)
}
/// Split a diff block into individual hunks, preserving file headers
fn split_into_hunks(diff: &str) -> Vec<String> {
let mut hunks = Vec::new();
let mut current_file_header: Option<String> = None;
let mut current_hunk: Vec<String> = Vec::new();
let mut in_hunk = false;
for line in diff.lines() {
if line.starts_with("--- a/") || line.starts_with("--- /") {
// Start of file header - flush previous hunk
if in_hunk && !current_hunk.is_empty() {
let mut hunk_text = String::new();
if let Some(ref header) = current_file_header {View on GitHub (pinned to f4178619ac)
Solutions
- Check the raw response for a missing or malformed ``` fence after the section marker
- Retry with a stricter prompt showing the exact fence format expected
- As a code-level option, extend extract_diff_block to also accept hunks starting with `diff --git`/`--- ` outside fences
Defensive patterns
Strategy: retry
Validate before calling
fn has_fenced_block_after(text: &str, marker: &str) -> bool {
text.find(marker)
.map(|i| text[i + marker.len()..].contains("```"))
.unwrap_or(false)
} Type guard
fn has_fenced_block_after(text: &str, marker: &str) -> bool {
text.find(marker)
.map(|i| text[i + marker.len()..].contains("```"))
.unwrap_or(false)
} Try / catch
Distinguish 'section missing' from 'section present but unfenced' in the caught error; retry the latter with an explicit instruction to wrap the diff in triple-backtick fences.
Prevention
- Show the exact fenced format in the prompt example
- Pre-scan model output for ``` fences under each section marker before full parsing
- If a model consistently omits fences, switch models or accept unfenced hunks via a parser extension
When it happens
Trigger: The model writes prose or bare diff text under the heading without a fenced code block, or uses malformed fences (four backticks, indented fences) so the block scanner cannot find a ``` pair after the marker.
Common situations: Models describing the edit in natural language instead of a diff; fence style variation across models; markdown escaping in intermediate processing.
Related errors
- No edit history hunks found in response
- No expected patch hunks found in response
- sweep prompt {field_name} contains reserved tokens
- --languages and/or --extensions is required (use --list to s
- unknown teacher backend `{s}`. Valid options: sonnet45, sonn
AI-assisted analysis of zed-industries/zed@f4178619ac (2026-08-20).
Data as JSON: /api/errors/05af470ae63d6363.
Report an issue: GitHub.