{"record":{"id":"04678c588d4d24fb","repo":"astral-sh/ruff","slug":"tried-to-open-unavailable-document-key","errorCode":null,"errorMessage":"Tried to open unavailable document `{key}`","messagePattern":"Tried to open unavailable document `(.+?)`","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/ruff_server/src/session/index.rs","lineNumber":156,"sourceCode":"        }\n    }\n\n    pub(super) fn update_notebook_document(\n        &mut self,\n        key: &DocumentKey,\n        cells: Option<lsp_types::NotebookDocumentCellChanges>,\n        metadata: Option<serde_json::Map<String, serde_json::Value>>,\n        new_version: DocumentVersion,\n        encoding: PositionEncoding,\n    ) -> crate::Result<()> {\n        // update notebook cell index\n        if let Some(lsp_types::NotebookDocumentCellChangeStructure {\n            did_open: Some(did_open),\n            ..\n        }) = cells.as_ref().and_then(|cells| cells.structure.as_ref())\n        {\n            let Some(path) = self.uri_for_key(key).cloned() else {\n                anyhow::bail!(\"Tried to open unavailable document `{key}`\");\n            };\n\n            for opened_cell in did_open {\n                self.notebook_cells\n                    .insert(opened_cell.uri.clone(), path.clone());\n            }\n            // deleted notebook cells are closed via textDocument/didClose - we don't close them here.\n        }\n\n        let controller = self.document_controller_for_key(key)?;\n        let Some(notebook) = controller.as_notebook_mut() else {\n            anyhow::bail!(\"Notebook document URI does not point to a notebook document\");\n        };\n\n        notebook.update(cells, metadata, new_version, encoding)?;\n        Ok(())\n    }\n","sourceCodeStart":138,"sourceCodeEnd":174,"githubUrl":"https://github.com/astral-sh/ruff/blob/672bb4edf04c84f8b0753346359daee4057158f2/crates/ruff_server/src/session/index.rs#L138-L174","documentation":"Error \"Tried to open unavailable document `{key}`\" thrown in astral-sh/ruff.","triggerScenarios":"Thrown at crates/ruff_server/src/session/index.rs:156 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"672bb4edf04c84f8b0753346359daee4057158f2","analyzedAt":"2026-08-16T08:54:05.464Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}