{"record":{"id":"d93a396c2d4c13f0","repo":"zed-industries/zed","slug":"invalid-editable-region-markers","errorCode":null,"errorMessage":"Invalid editable region markers","messagePattern":"Invalid editable region markers","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/edit_prediction_cli/src/format_prompt.rs","lineNumber":323,"sourceCode":"        result.push_str(Self::EDITABLE_REGION_START);\n        result.push_str(&excerpt[editable_range.start..cursor_offset]);\n        result.push_str(Self::USER_CURSOR_MARKER);\n        result.push_str(&excerpt[cursor_offset..editable_range.end]);\n        result.push_str(Self::EDITABLE_REGION_END);\n        result.push_str(&excerpt[editable_range.end..context_range.end]);\n        result.push_str(\"\\n`````\");\n\n        result\n    }\n\n    pub fn extract_editable_region(text: &str) -> Result<String> {\n        let start = text\n            .rfind(Self::EDITABLE_REGION_START)\n            .map_or(0, |pos| pos + Self::EDITABLE_REGION_START.len());\n        let end = text.rfind(Self::EDITABLE_REGION_END).unwrap_or(text.len());\n\n        if start >= end {\n            return Err(anyhow!(\"Invalid editable region markers\"));\n        }\n\n        let region = &text[start..end];\n        Ok(region.strip_suffix('\\n').unwrap_or(region).to_string())\n    }\n\n    fn format_diagnostics(example: &Example) -> String {\n        let Some(prompt_inputs) = example.prompt_inputs.as_ref() else {\n            return \"No Diagnostics\".to_string();\n        };\n\n        let cursor_buffer_row = prompt_inputs.excerpt_start_row.map(|excerpt_start_row| {\n            excerpt_start_row\n                + prompt_inputs.cursor_excerpt[..prompt_inputs.cursor_offset_in_excerpt]\n                    .bytes()\n                    .filter(|byte| *byte == b'\\n')\n                    .count() as u32\n        });","sourceCodeStart":305,"sourceCodeEnd":341,"githubUrl":"https://github.com/zed-industries/zed/blob/f4178619acd0d47ea1f76a2025c42962c6d6638c/crates/edit_prediction_cli/src/format_prompt.rs#L305-L341","documentation":"extract_editable_region looks for the marker-delimited editable span inside a model response; when the start/end markers do not form a recognizable region, the response is rejected as malformed. The model output (or corrupted example data) is the input at fault.","triggerScenarios":"Thrown at crates/edit_prediction_cli/src/format_prompt.rs:323 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify the model response actually contains the editable-region markers","Regenerate the example/response if the markers were truncated"],"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"}