zed-industries/zed · error

Invalid editable region markers

Error message

Invalid editable region markers

What it means

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.

Source

Thrown at crates/edit_prediction_cli/src/format_prompt.rs:323

        result.push_str(Self::EDITABLE_REGION_START);
        result.push_str(&excerpt[editable_range.start..cursor_offset]);
        result.push_str(Self::USER_CURSOR_MARKER);
        result.push_str(&excerpt[cursor_offset..editable_range.end]);
        result.push_str(Self::EDITABLE_REGION_END);
        result.push_str(&excerpt[editable_range.end..context_range.end]);
        result.push_str("\n`````");

        result
    }

    pub fn extract_editable_region(text: &str) -> Result<String> {
        let start = text
            .rfind(Self::EDITABLE_REGION_START)
            .map_or(0, |pos| pos + Self::EDITABLE_REGION_START.len());
        let end = text.rfind(Self::EDITABLE_REGION_END).unwrap_or(text.len());

        if start >= end {
            return Err(anyhow!("Invalid editable region markers"));
        }

        let region = &text[start..end];
        Ok(region.strip_suffix('\n').unwrap_or(region).to_string())
    }

    fn format_diagnostics(example: &Example) -> String {
        let Some(prompt_inputs) = example.prompt_inputs.as_ref() else {
            return "No Diagnostics".to_string();
        };

        let cursor_buffer_row = prompt_inputs.excerpt_start_row.map(|excerpt_start_row| {
            excerpt_start_row
                + prompt_inputs.cursor_excerpt[..prompt_inputs.cursor_offset_in_excerpt]
                    .bytes()
                    .filter(|byte| *byte == b'\n')
                    .count() as u32
        });

View on GitHub (pinned to f4178619ac)

Solutions

  1. Verify the model response actually contains the editable-region markers
  2. Regenerate the example/response if the markers were truncated
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/edit_prediction_cli/src/format_prompt.rs:323 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of zed-industries/zed@f4178619ac (2026-08-20). Data as JSON: /api/errors/d93a396c2d4c13f0. Report an issue: GitHub.