{"record":{"id":"de4d908802bbdf35","repo":"zed-industries/zed","slug":"edit-span-start-id-end-id-looks-truncated","errorCode":null,"errorMessage":"edit span `{start_id}`..`{end_id}` looks truncated: the replacement stops before the end marker, which would silently delete:\n{dropped}","messagePattern":"edit span `(.+?)`\\.\\.`(.+?)` looks truncated: the replacement stops before the end marker, which would silently delete:\n(.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/zeta_prompt/src/hashed_regions.rs","lineNumber":709,"sourceCode":"        let cursor_in_span = raw_new_span.find(cursor_marker);\n        let mut new_span = raw_new_span.replace(cursor_marker, \"\");\n        if old_span.is_empty() {\n            if !new_span.is_empty() && !new_span.ends_with('\\n') {\n                new_span.push('\\n');\n            }\n        } else {\n            if old_span.ends_with('\\n') && !new_span.ends_with('\\n') && !new_span.is_empty() {\n                new_span.push('\\n');\n            }\n            if !old_span.ends_with('\\n') && new_span.ends_with('\\n') {\n                new_span.pop();\n            }\n        }\n\n        if !new_span.is_empty()\n            && let Some(dropped) = detect_trailing_deletion(old_span, &new_span)\n        {\n            return Err(anyhow!(\n                \"edit span `{start_id}`..`{end_id}` looks truncated: the replacement \\\n                 stops before the end marker, which would silently delete:\\n{dropped}\"\n            ));\n        }\n\n        // `cursor_in_span` was located in `raw_new_span` before the trailing\n        // newline normalization above, which can drop a byte. Clamp it to the\n        // finalized replacement so the offset never points past `new_span`\n        // (downstream cursor mapping byte-slices `new_text` by this offset).\n        let cursor_offset_in_new_text = cursor_in_span.map(|offset| offset.min(new_span.len()));\n        edits.push(ParsedSpanEdit {\n            snippet_ix: start_snippet,\n            range: start_byte..end_byte,\n            new_text: new_span,\n            cursor_offset_in_new_text,\n        });\n    }\n","sourceCodeStart":691,"sourceCodeEnd":727,"githubUrl":"https://github.com/zed-industries/zed/blob/f4178619acd0d47ea1f76a2025c42962c6d6638c/crates/zeta_prompt/src/hashed_regions.rs#L691-L727","documentation":"Safety check in build_patch_from_spans: the replacement text stops before the end marker, so applying it would silently delete the trailing original content (`dropped`); the patch is rejected instead of losing code.","triggerScenarios":"Thrown at crates/zeta_prompt/src/hashed_regions.rs:709 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Retry so the model reproduces the full span up to the end marker","Manually apply the intended edit"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"f4178619acd0d47ea1f76a2025c42962c6d6638c","analyzedAt":"2026-08-20T19:29:52.058Z","contentChangedAt":"2026-08-20T19:29:52.058Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}