{"record":{"id":"c7508e0de52359f7","repo":"zed-industries/zed","slug":"invalid-transformation-range","errorCode":null,"errorMessage":"invalid transformation range","messagePattern":"invalid transformation range","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/agent_ui/src/buffer_codegen.rs","lineNumber":484,"sourceCode":"            if Arc::ptr_eq(language, &language::PLAIN_TEXT) {\n                None\n            } else {\n                Some(language.name())\n            }\n        } else {\n            None\n        };\n\n        let language_name = language_name.as_ref();\n        let start = buffer.point_to_buffer_offset(self.range.start);\n        let end = buffer.point_to_buffer_offset(self.range.end);\n        let (buffer, range) = if let Some((start, end)) = start.zip(end) {\n            let (start_buffer, start_buffer_offset) = start;\n            let (end_buffer, end_buffer_offset) = end;\n            if start_buffer.remote_id() == end_buffer.remote_id() {\n                (start_buffer.clone(), start_buffer_offset..end_buffer_offset)\n            } else {\n                anyhow::bail!(\"invalid transformation range\");\n            }\n        } else {\n            anyhow::bail!(\"invalid transformation range\");\n        };\n\n        let system_prompt = self\n            .builder\n            .generate_inline_transformation_prompt_tools(\n                language_name,\n                buffer,\n                range.start.0..range.end.0,\n            )\n            .context(\"generating content prompt\")?;\n\n        let temperature = AgentSettings::temperature_for_model(model, cx);\n        let session_id = self.session_id.to_string();\n\n        let tool_choice = model","sourceCodeStart":466,"sourceCodeEnd":502,"githubUrl":"https://github.com/zed-industries/zed/blob/916fc2b8cb3a815cbef4a3b40e13081be72036b6/crates/agent_ui/src/buffer_codegen.rs#L466-L502","documentation":"Building the inline-assist request (tool-streaming variant, `build_request_tools`), the selected range's start and end points are mapped through `point_to_buffer_offset` on a multi-buffer snapshot. Both resolve, but into different underlying buffers (`start_buffer.remote_id() != end_buffer.remote_id()`), so there is no single buffer to transform and the request is rejected.","triggerScenarios":"Invoking inline transformation (edit/transform selection) with a selection spanning two excerpts of a multi-buffer — e.g. a search-results buffer or a project search tab where the selection crosses from one file's excerpt into another.","commonSituations":"Select-all in a multi-buffer view then triggering inline assist; a selection that starts at the end of one file's excerpt and extends into the next; project-wide search buffers holding results from multiple files.","solutions":["Restrict the selection to a single file/excerpt and re-run the inline transformation.","Open the specific file in its own editor buffer (not the multi-buffer) and select there.","Run the transformation per file with one range each instead of one cross-file range.","In code building on these crates, pre-check both endpoints resolve to the same `remote_id` before building the request."],"exampleFix":"// caller-side guard, before building the request\n// before\nlet request = transformation.build_request_tools(model, prompt, ctx, cx)?;\n\n// after\nlet snapshot = buffer.read(cx).snapshot(cx);\nlet ok = snapshot.point_to_buffer_offset(range.start)\n    .zip(snapshot.point_to_buffer_offset(range.end))\n    .map(|(s, e)| s.0.remote_id() == e.0.remote_id())\n    .unwrap_or(false);\nif !ok {\n    return anyhow::bail!(\"select within a single file\");\n}\nlet request = transformation.build_request_tools(model, prompt, ctx, cx)?;","handlingStrategy":"type-guard","validationCode":"let snapshot = buffer.read(cx).snapshot(cx);\nif let (Some((sb, _)), Some((eb, _))) = (\n    snapshot.point_to_buffer_offset(range.start),\n    snapshot.point_to_buffer_offset(range.end),\n) {\n    if sb.remote_id() != eb.remote_id() {\n        // cross-file selection: reject before building the inline-assist request\n    }\n}","typeGuard":"fn range_in_single_buffer(\n    snapshot: &MultiBufferSnapshot,\n    range: Range<Point>,\n) -> bool {\n    match (snapshot.point_to_buffer_offset(range.start), snapshot.point_to_buffer_offset(range.end)) {\n        (Some((sb, _)), Some((eb, _))) => sb.remote_id() == eb.remote_id(),\n        _ => false,\n    }\n}","tryCatchPattern":"match codegen.build_request_tools(model, prompt, ctx, cx) {\n    Err(e) if e.to_string() == \"invalid transformation range\" => {\n        // ask the user to re-select within one file, then retry\n    }\n    rest => rest,\n}","preventionTips":["Run inline assist from a single-file editor, not a multi-buffer view.","Check both endpoints map to the same buffer before showing inline-assist UI.","Split cross-file edits into one invocation per file."],"tags":["rust","zed","gpui","inline-assist","multi-buffer","range","buffer-codegen"],"backgroundTag":"invalid-buffer-range","analyzedSha":"916fc2b8cb3a815cbef4a3b40e13081be72036b6","analyzedAt":"2026-08-20T19:29:52.058Z","contentChangedAt":"2026-08-20T19:29:52.058Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}