{"record":{"id":"3af3b6e3dd35bf23","repo":"astral-sh/ruff","slug":"internalerror","errorCode":"InternalError","errorMessage":"Notebook document expected from notebook source kind","messagePattern":"Notebook document expected from notebook source kind","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/ruff_server/src/fix.rs","lineNumber":107,"sourceCode":"    }\n\n    // fast path: if `transformed` is still borrowed, no changes were made and we can return early\n    if let Cow::Borrowed(_) = transformed {\n        return Ok(Fixes::default());\n    }\n\n    if let (Some(source_notebook), Some(modified_notebook)) =\n        (source_kind.as_ipy_notebook(), transformed.as_ipy_notebook())\n    {\n        fn cell_source(cell: &ruff_notebook::Cell) -> String {\n            match cell.source() {\n                SourceValue::String(string) => string.clone(),\n                SourceValue::StringArray(array) => array.join(\"\"),\n            }\n        }\n\n        let Some(notebook) = query.as_notebook() else {\n            anyhow::bail!(\"Notebook document expected from notebook source kind\");\n        };\n        let mut fixes = Fixes::default();\n        for ((source, modified), uri) in source_notebook\n            .cells()\n            .iter()\n            .map(cell_source)\n            .zip(modified_notebook.cells().iter().map(cell_source))\n            .zip(notebook.uris())\n        {\n            let source_index = LineIndex::from_source_text(&source);\n            let modified_index = LineIndex::from_source_text(&modified);\n\n            let Replacement {\n                source_range,\n                modified_range,\n            } = Replacement::between(\n                &source,\n                source_index.line_starts(),","sourceCodeStart":89,"sourceCodeEnd":125,"githubUrl":"https://github.com/astral-sh/ruff/blob/d1087a4b9e03d253a88703f34e0869ee4b805456/crates/ruff_server/src/fix.rs#L89-L125","documentation":"An InternalError from the ruff language server's fix pipeline: the document being fixed was classified as an ipynb notebook (source kind and transformed content both parsed as notebooks), but the session's stored query document could not be retrieved as a notebook. This is a broken internal invariant between the source-kind detection and the session document index, not a user configuration issue.","triggerScenarios":"Applying a code action / auto-fix on a .ipynb notebook open in the editor when the server's document index holds a stale or mismatched entry for that URI; typically after notebook cells were opened/closed rapidly or the server state desynchronized.","commonSituations":"Editor extension races during notebook editing; server restarted mid-session while notebook documents remained open; version skew between editor extension and ruff server.","solutions":["Restart the ruff language server / reload the editor window to rebuild the document index","Update the ruff VS Code extension (and bundled server) — state-desync bugs in the notebook fix path get fixed over time","If reproducible, capture the editor logs and file an issue at https://github.com/astral-sh/ruff/issues with the notebook and steps"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep the ruff server and editor extension on matching, current versions","After rapid notebook cell open/close churn, restart the server if fixes start failing","Capture editor LSP logs when it reproduces so the state mismatch can be reported precisely"],"tags":["lsp","ruff-server","notebook","internal-error","state-desync"],"backgroundTag":"lsp-state-desync","analyzedSha":"d1087a4b9e03d253a88703f34e0869ee4b805456","analyzedAt":"2026-08-20T16:33:49.445Z","contentChangedAt":"2026-08-20T16:33:49.445Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}