{"record":{"id":"05af470ae63d6363","repo":"zed-industries/zed","slug":"no-diff-blocks-found-in-section","errorCode":null,"errorMessage":"No diff blocks found in section {}","messagePattern":"No diff blocks found in section (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/edit_prediction_cli/src/synthesize.rs","lineNumber":658,"sourceCode":"            .find('\\n')\n            .map(|i| abs_diff_start + i + 1)\n            .unwrap_or(abs_diff_start);\n\n        if let Some(block_end_rel) = section_content[block_content_start..].find(\"```\") {\n            let block_end = block_content_start + block_end_rel;\n            let diff_content = section_content[block_content_start..block_end].trim();\n\n            // Split this block into hunks (in case multiple hunks in one block)\n            hunks.extend(split_into_hunks(diff_content));\n\n            search_start = block_end + 3;\n        } else {\n            break;\n        }\n    }\n\n    if hunks.is_empty() {\n        anyhow::bail!(\"No diff blocks found in section {}\", section_marker);\n    }\n\n    Ok(hunks)\n}\n\n/// Split a diff block into individual hunks, preserving file headers\nfn split_into_hunks(diff: &str) -> Vec<String> {\n    let mut hunks = Vec::new();\n    let mut current_file_header: Option<String> = None;\n    let mut current_hunk: Vec<String> = Vec::new();\n    let mut in_hunk = false;\n\n    for line in diff.lines() {\n        if line.starts_with(\"--- a/\") || line.starts_with(\"--- /\") {\n            // Start of file header - flush previous hunk\n            if in_hunk && !current_hunk.is_empty() {\n                let mut hunk_text = String::new();\n                if let Some(ref header) = current_file_header {","sourceCodeStart":640,"sourceCodeEnd":676,"githubUrl":"https://github.com/zed-industries/zed/blob/f4178619acd0d47ea1f76a2025c42962c6d6638c/crates/edit_prediction_cli/src/synthesize.rs#L640-L676","documentation":"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.","triggerScenarios":"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.","commonSituations":"Models describing the edit in natural language instead of a diff; fence style variation across models; markdown escaping in intermediate processing.","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"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"fn has_fenced_block_after(text: &str, marker: &str) -> bool {\n    text.find(marker)\n        .map(|i| text[i + marker.len()..].contains(\"```\"))\n        .unwrap_or(false)\n}","typeGuard":"fn has_fenced_block_after(text: &str, marker: &str) -> bool {\n    text.find(marker)\n        .map(|i| text[i + marker.len()..].contains(\"```\"))\n        .unwrap_or(false)\n}","tryCatchPattern":"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.","preventionTips":["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"],"tags":["llm-parsing","synthesize","diff","edit-prediction","rust"],"backgroundTag":"llm-response-parse-failed","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"}