{"record":{"id":"a68951adc68bcf79","repo":"zed-industries/zed","slug":"relative-marker-maps-before-first-marker","errorCode":null,"errorMessage":"relative marker maps before first marker","messagePattern":"relative marker maps before first marker","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/zeta_prompt/src/multi_region.rs","lineNumber":841,"sourceCode":"            .context(\"end marker number out of range\")?;\n        Ok((start_byte, end_byte))\n    })\n}\n\npub fn apply_marker_span_v0317(\n    old_editable: &str,\n    output: &str,\n    cursor_offset_in_old: Option<usize>,\n) -> Result<String> {\n    let tags = collect_relative_marker_tags(output);\n    let marker_offsets = compute_marker_offsets(old_editable);\n    let anchor_idx = cursor_block_index(cursor_offset_in_old, &marker_offsets);\n\n    apply_marker_span_impl(old_editable, &tags, output, |start_delta, end_delta| {\n        let start_idx_signed = anchor_idx as isize + start_delta;\n        let end_idx_signed = anchor_idx as isize + end_delta;\n        if start_idx_signed < 0 || end_idx_signed < 0 {\n            return Err(anyhow!(\"relative marker maps before first marker\"));\n        }\n        let start_idx = usize::try_from(start_idx_signed).context(\"invalid start marker index\")?;\n        let end_idx = usize::try_from(end_idx_signed).context(\"invalid end marker index\")?;\n        let start_byte = *marker_offsets\n            .get(start_idx)\n            .context(\"start marker number out of range\")?;\n        let end_byte = *marker_offsets\n            .get(end_idx)\n            .context(\"end marker number out of range\")?;\n        Ok((start_byte, end_byte))\n    })\n}\n\npub fn apply_marker_span_v0318(old_editable: &str, output: &str) -> Result<String> {\n    let tags = collect_marker_tags(output);\n\n    if tags.len() >= 2 {\n        let start_num = tags[0].value;","sourceCodeStart":823,"sourceCodeEnd":859,"githubUrl":"https://github.com/zed-industries/zed/blob/f4178619acd0d47ea1f76a2025c42962c6d6638c/crates/zeta_prompt/src/multi_region.rs#L823-L859","documentation":"In the v0317 relative-marker scheme, the cursor's anchor block index plus the model-supplied negative delta resolved to an index before the first marker (below zero), so the start boundary would fall outside the editable region.","triggerScenarios":"Thrown at crates/zeta_prompt/src/multi_region.rs:841 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Clamp the resolved index to the first marker instead of erroring, if the intended span is the region start","Reject the output and re-prompt, since the relative offset is inconsistent with the cursor anchor","Ensure the cursor offset passed in actually lies inside the editable region's marker blocks"],"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"}