{"record":{"id":"910427680900eb94","repo":"BoundaryML/baml","slug":"32801-content-modified-0","errorCode":"-32801","errorMessage":"Content modified: {0}","messagePattern":"Content modified: (.+?)","errorType":"error_code","errorClass":"LspError","httpStatus":null,"severity":"info","filePath":"baml_language/crates/baml_lsp/src/error.rs","lineNumber":46,"sourceCode":"    /// `-32803`).\n    #[error(\"LSP outbound frame exceeds the transport limit\")]\n    OutboundOversized,\n    #[error(\"Invalid command arguments for command: {command}: {message}\")]\n    InvalidCommandArguments { command: String, message: String },\n    #[error(\"File not found: {}\", .0.display())]\n    FileNotFound(PathBuf),\n    #[error(\"Path is invalid: {}: {message}\", path.display())]\n    InvalidPath { path: PathBuf, message: String },\n    /// The document's path is under no known source root.\n    #[error(\"No source root contains {}\", .0.display())]\n    NoRootForPath(PathBuf),\n    /// Cancellation claimed the response while the request was queued or\n    /// running (LSP `RequestCanceled`, `-32800`).\n    #[error(\"Request canceled: {0}\")]\n    RequestCanceled(String),\n    /// The request's snapshot became stale under an applied source change\n    /// (LSP `ContentModified`, `-32801`).\n    #[error(\"Content modified: {0}\")]\n    ContentModified(String),\n    /// A valid request that cannot be served right now (LSP `RequestFailed`,\n    /// `-32803`).\n    #[error(\"{0}\")]\n    RequestFailed(String),\n    /// Violated invariants, panics, serialization (LSP `InternalError`,\n    /// `-32603`).\n    #[error(\"Internal error: {0}\")]\n    Internal(String),\n    /// Malformed params, position, or range (LSP `InvalidParams`, `-32602`).\n    #[error(\"Invalid params: {0}\")]\n    InvalidParams(String),\n    /// A request before `initialize` completed (LSP `ServerNotInitialized`,\n    /// `-32002`).\n    #[error(\"Server not initialized: {0}\")]\n    ServerNotInitialized(String),\n}\n","sourceCodeStart":28,"sourceCodeEnd":64,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/baml_language/crates/baml_lsp/src/error.rs#L28-L64","documentation":"LspError::ContentModified indicates the request's snapshot of a document became stale because an edit was applied while the request was queued or executing. It maps to the LSP ContentModified code -32801. This lets the client know the result would not reflect the current document state and should be re-issued against the newer version.","triggerScenarios":"A didChange notification arrives between when a request (completion, code action, formatting) was received and when its result is computed; the document version the request was based on no longer matches the server's current version.","commonSituations":"Fast typing during completion/compute-diagnostics; auto-save or format-on-save racing an in-flight request; batch tooling editing files while analysis requests are pending.","solutions":["Client should catch code -32801 and simply re-send the request with the current document version.","Sequence requests so that a didChange invalidates/supersedes previously issued analysis requests.","Avoid editing the document programmatically while awaiting dependent requests (formatters, code actions).","Enable request debouncing/throttling in the client to reduce races with edits."],"exampleFix":"// before\nconst edits = await request('textDocument/formatting', params);\n// after\nasync function format(params) {\n  try {\n    return await request('textDocument/formatting', params);\n  } catch (e) {\n    if (e.code === -32801) return format(params); // retry on stale snapshot\n    throw e;\n  }\n}","handlingStrategy":"retry","validationCode":null,"typeGuard":"function isContentModified(e) { return e?.code === -32801 || /Content modified/.test(e?.message ?? ''); }","tryCatchPattern":"async function withStaleRetry(fn, retries = 2) {\n  try { return await fn(); }\n  catch (e) {\n    if (isContentModified(e) && retries > 0) return withStaleRetry(fn, retries - 1);\n    throw e;\n  }\n}","preventionTips":["Version-gate requests: attach and check the document version","Suppress editing during awaited format/code-action requests","Debounce didChange-driven request storms"],"tags":["lsp","concurrency","document-sync","stale-state"],"backgroundTag":"content-modified","analyzedSha":"bd85ce9dee1463ff04d27efd20531013a4ff46c1","analyzedAt":"2026-09-12T03:38:25.718Z","contentChangedAt":"2026-09-12T03:38:25.718Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}