{"record":{"id":"74bcee665814d1a5","repo":"astral-sh/ruff","slug":"transformed-content-out-of-bounds-start-end","errorCode":null,"errorMessage":"Transformed content out of bounds ({start:?}..{end:?}) for cell at {idx:?}","messagePattern":"Transformed content out of bounds \\((.+?)\\.\\.(.+?)\\) for cell at (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/ruff_notebook/src/notebook.rs","lineNumber":313,"sourceCode":"    /// cell offsets need to be rebuilt.\n    ///\n    /// ## Panics\n    ///\n    /// Panics if the transformed content is out of bounds for any cell. This\n    /// can happen only if the cell offsets were not updated before calling\n    /// this method or the offsets were updated incorrectly.\n    fn update_cell_content(&mut self, transformed: &str) -> bool {\n        let mut missing_separator = false;\n\n        for (&idx, &[start, end]) in self\n            .valid_code_cells\n            .iter()\n            .zip(self.cell_offsets.array_windows::<2>())\n        {\n            let cell_content = transformed\n                .get(start.to_usize()..end.to_usize())\n                .unwrap_or_else(|| {\n                    panic!(\n                        \"Transformed content out of bounds ({start:?}..{end:?}) for cell at {idx:?}\"\n                    );\n                });\n            missing_separator |= !cell_content.ends_with(SYNTHETIC_CELL_SEPARATOR);\n            self.raw.cells[idx as usize].set_source(SourceValue::StringArray(\n                UniversalNewlineIterator::from(\n                    // We only need to strip the trailing newline which we added\n                    // while concatenating the cell contents.\n                    cell_content.strip_suffix('\\n').unwrap_or(cell_content),\n                )\n                .map(|line| line.as_full_str().to_string())\n                .collect::<Vec<_>>(),\n            ));\n        }\n\n        missing_separator\n    }\n","sourceCodeStart":295,"sourceCodeEnd":331,"githubUrl":"https://github.com/astral-sh/ruff/blob/26f38c119cac42e4d320ba08f09224fdec74af2c/crates/ruff_notebook/src/notebook.rs#L295-L331","documentation":"Panics in Notebook::update_cell_content when slicing the transformed source with a cell's recorded [start, end] offsets goes out of bounds of the new content. As documented on the method, this only happens if cell offsets were not updated (or were updated incorrectly) before rebuilding cell contents.","triggerScenarios":"Thrown at crates/ruff_notebook/src/notebook.rs:313 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Recompute cell_offsets before calling update_cell_content","Return false/propagate an error instead of panicking when offsets do not fit the transformed content"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"26f38c119cac42e4d320ba08f09224fdec74af2c","analyzedAt":"2026-09-05T10:32:37.492Z","contentChangedAt":"2026-09-05T10:32:37.492Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}