{"record":{"id":"6abb6035063b1eb7","repo":"zed-industries/zed","slug":"could-not-locate-prefix-lines","errorCode":null,"errorMessage":"could not locate prefix lines","messagePattern":"could not locate prefix lines","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/zeta_prompt/src/zeta_prompt.rs","lineNumber":4406,"sourceCode":"    ) -> Result<(Range<usize>, String)> {\n        let (prefix_context, rest) = model_output\n            .split_once(\"<|fim_middle|>\\n\")\n            .or_else(|| model_output.split_once(\"<|fim_middle|>\"))\n            .ok_or_else(|| anyhow::anyhow!(\"missing <|fim_middle|> in model output\"))?;\n\n        let (new_text, suffix_context) = rest\n            .split_once(\"<|fim_suffix|>\\n\")\n            .or_else(|| rest.split_once(\"<|fim_suffix|>\"))\n            .unwrap_or((rest, \"\"));\n\n        let suffix_context = if prefix_context.is_empty() && !suffix_context.is_empty() {\n            suffix_context.strip_prefix('\\n').unwrap_or(suffix_context)\n        } else {\n            suffix_context\n        };\n\n        let prefix_offset = find_substring_at_line_boundary(context, prefix_context)\n            .ok_or_else(|| anyhow!(\"could not locate prefix lines\"))?\n            + prefix_context.len();\n        let suffix_offset = if suffix_context.is_empty() {\n            context.len()\n        } else {\n            find_substring_at_line_boundary(&context[prefix_offset..], suffix_context)\n                .ok_or_else(|| anyhow!(\"could not locate suffix lines\"))?\n                + prefix_offset\n        };\n\n        let edit_range = prefix_offset..suffix_offset;\n        return Ok((edit_range, new_text.to_string()));\n    }\n\n    fn find_substring_at_line_boundary(haystack: &str, needle: &str) -> Option<usize> {\n        if needle.is_empty() {\n            return Some(0);\n        }\n","sourceCodeStart":4388,"sourceCodeEnd":4424,"githubUrl":"https://github.com/zed-industries/zed/blob/f4178619acd0d47ea1f76a2025c42962c6d6638c/crates/zeta_prompt/src/zeta_prompt.rs#L4388-L4424","documentation":"The prefix context lines echoed by the model could not be found at a line boundary in the original text, so the replacement start offset is unknown. Typically the model hallucinated or altered the prefix context.","triggerScenarios":"Thrown at crates/zeta_prompt/src/zeta_prompt.rs:4406 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Retry the request so the model reproduces the prefix context verbatim","Fall back to fuzzy line matching on the prefix before failing","Validate the prefix against the current buffer before applying"],"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-14T05:17:10.506Z"}