{"record":{"id":"c6afea4bef2c7220","repo":"zed-industries/zed","slug":"could-not-locate-suffix-lines","errorCode":null,"errorMessage":"could not locate suffix lines","messagePattern":"could not locate suffix lines","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/zeta_prompt/src/zeta_prompt.rs","lineNumber":4412,"sourceCode":"        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\n        haystack.match_indices(needle).find_map(|(offset, _)| {\n            let matched_line_start = offset == 0 || haystack[..offset].ends_with('\\n');\n            matched_line_start.then_some(offset)\n        })\n    }\n","sourceCodeStart":4394,"sourceCodeEnd":4430,"githubUrl":"https://github.com/zed-industries/zed/blob/f4178619acd0d47ea1f76a2025c42962c6d6638c/crates/zeta_prompt/src/zeta_prompt.rs#L4394-L4430","documentation":"The suffix context lines echoed by the model could not be located at a line boundary in the original text after the prefix, so the replacement end offset is unknown. The model's suffix context drifted from the actual buffer content.","triggerScenarios":"Thrown at crates/zeta_prompt/src/zeta_prompt.rs:4412 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Retry the request for a verbatim suffix context","Use fuzzy or whitespace-insensitive suffix matching as a fallback","Reject the edit when suffix context cannot be trusted"],"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"}