{"record":{"id":"8dac663bf4057b77","repo":"BoundaryML/baml","slug":"32603-internal-error-0","errorCode":"-32603","errorMessage":"Internal error: {0}","messagePattern":"Internal error: (.+?)","errorType":"error_code","errorClass":"LspError","httpStatus":null,"severity":"critical","filePath":"baml_language/crates/baml_lsp/src/error.rs","lineNumber":54,"sourceCode":"    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\nimpl LspError {\n    /// The one LSP error-code mapping.\n    #[must_use]\n    pub fn to_response_error(&self) -> lsp_server::ResponseError {\n        use lsp_server::ErrorCode;\n        let code = match self {\n            LspError::NotificationExtractError(_)\n            | LspError::RequestExtractError(_)","sourceCodeStart":36,"sourceCodeEnd":72,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/baml_language/crates/baml_lsp/src/error.rs#L36-L72","documentation":"LspError::Internal signals that the server violated its own invariants, panicked, or failed to serialize a response. It maps to the LSP InternalError code -32603 and prefixes the payload with 'Internal error:'. This is a bug-class error: it should never result from bad client input, only from defects or unexpected states inside baml_lsp.","triggerScenarios":"A request handler panics on unexpected document content; serde serialization of a response fails; an invariant such as 'document must be open' or 'index must contain file' is violated.","commonSituations":"Edge-case .baml source triggering a parser/analysis panic; version skew between server internals and generated types; corrupted or partially-written files read during analysis.","solutions":["Capture the full message and the request that triggered it and file a bug against baml_lsp.","Update to the latest baml_lsp/server version, as internal errors are usually fixed in newer releases.","Minimize a reproducing document (the .baml content) and remove it from the project as a workaround.","Check server logs/stack traces around the error for the underlying panic or serialization failure."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":"function isInternalError(e) { return e?.code === -32603 || /Internal error:/.test(e?.message ?? ''); }","tryCatchPattern":"try {\n  return await request(method, params);\n} catch (e) {\n  if (isInternalError(e)) {\n    reportBug({ method, params, message: e.message }); // file against baml_lsp\n    return null;\n  }\n  throw e;\n}","preventionTips":["Keep the BAML server/extension updated to the latest release","Capture and attach full error messages plus triggering documents in bug reports","Avoid feeding corrupted or partially written files to the server"],"tags":["lsp","bug","panic","internal-error"],"backgroundTag":"internal-invariant-violation","analyzedSha":"bd85ce9dee1463ff04d27efd20531013a4ff46c1","analyzedAt":"2026-09-12T03:38:25.718Z","contentChangedAt":"2026-09-12T03:38:25.718Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}