BoundaryML/baml · critical · LspError
-32603
-32603
Error message
Internal error: {0} What it means
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.
Source
Thrown at baml_language/crates/baml_lsp/src/error.rs:54
InvalidPath { path: PathBuf, message: String },
/// The document's path is under no known source root.
#[error("No source root contains {}", .0.display())]
NoRootForPath(PathBuf),
/// Cancellation claimed the response while the request was queued or
/// running (LSP `RequestCanceled`, `-32800`).
#[error("Request canceled: {0}")]
RequestCanceled(String),
/// The request's snapshot became stale under an applied source change
/// (LSP `ContentModified`, `-32801`).
#[error("Content modified: {0}")]
ContentModified(String),
/// A valid request that cannot be served right now (LSP `RequestFailed`,
/// `-32803`).
#[error("{0}")]
RequestFailed(String),
/// Violated invariants, panics, serialization (LSP `InternalError`,
/// `-32603`).
#[error("Internal error: {0}")]
Internal(String),
/// Malformed params, position, or range (LSP `InvalidParams`, `-32602`).
#[error("Invalid params: {0}")]
InvalidParams(String),
/// A request before `initialize` completed (LSP `ServerNotInitialized`,
/// `-32002`).
#[error("Server not initialized: {0}")]
ServerNotInitialized(String),
}
impl LspError {
/// The one LSP error-code mapping.
#[must_use]
pub fn to_response_error(&self) -> lsp_server::ResponseError {
use lsp_server::ErrorCode;
let code = match self {
LspError::NotificationExtractError(_)
| LspError::RequestExtractError(_)View on GitHub (pinned to bd85ce9dee)
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.
Defensive patterns
Strategy: try-catch
Type guard
function isInternalError(e) { return e?.code === -32603 || /Internal error:/.test(e?.message ?? ''); } Try / catch
try {
return await request(method, params);
} catch (e) {
if (isInternalError(e)) {
reportBug({ method, params, message: e.message }); // file against baml_lsp
return null;
}
throw e;
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.
Related errors
- Function panicked: {s}
- internal error: attempted to register unknown function '%s'
- InternalError
- InternalError
- `{field_name}: int` is outside BAML int range [{}, {}], got
AI-assisted analysis of BoundaryML/baml@bd85ce9dee (2026-09-12).
Data as JSON: /api/errors/8dac663bf4057b77.
Report an issue: GitHub.