BoundaryML/baml · error · LspError

Invalid command arguments for command: {command}: {message}

Error message

Invalid command arguments for command: {command}: {message}

What it means

LspError::InvalidCommandArguments is raised when the baml_lsp language server receives a workspace/executeCommand request whose arguments do not match what the named command expects (wrong count, wrong types, or unparseable payload). The error carries the command name and a descriptive message so the client can tell which command rejected its arguments. It maps to a JSON-RPC error response rather than a crash, since bad arguments are a client-side problem.

Source

Thrown at baml_language/crates/baml_lsp/src/error.rs:31

    #[error("Notification not supported: {0}")]
    NotificationNotSupported(String),
    #[error("{0}")]
    RequestExtractError(lsp_server::ExtractError<lsp_server::Request>),
    #[error("Request not supported: {0}")]
    RequestNotSupported(String),
    #[error("Failed to serialize request result: {0}")]
    RequestSerializeError(serde_json::Error),
    /// The client's sink is gone; nothing more can be delivered.
    #[error("Client closed")]
    ClientClosed,
    /// Bounded transport backpressure (LSP `RequestFailed`, `-32803`).
    #[error("LSP outbound sink is saturated")]
    OutboundSaturated,
    /// A frame larger than the transport limit (LSP `RequestFailed`,
    /// `-32803`).
    #[error("LSP outbound frame exceeds the transport limit")]
    OutboundOversized,
    #[error("Invalid command arguments for command: {command}: {message}")]
    InvalidCommandArguments { command: String, message: String },
    #[error("File not found: {}", .0.display())]
    FileNotFound(PathBuf),
    #[error("Path is invalid: {}: {message}", path.display())]
    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`).

View on GitHub (pinned to bd85ce9dee)

Solutions

  1. Log the command name and arguments on the client side and compare against the command's expected parameter signature in baml_lsp.
  2. Update the client extension/tooling to match the server's current command argument schema.
  3. Ensure arguments are JSON-serializable values of the exact expected types (numbers as numbers, positions as {line, character}, etc.).
  4. Re-run the LSP initialize handshake so the client picks up the server's current command registrations.

Example fix

// before
client.sendRequest('workspace/executeCommand', {
  command: 'baml.generate',
  arguments: ["file.baml"]
});
// after
client.sendRequest('workspace/executeCommand', {
  command: 'baml.generate',
  arguments: [{ textDocument: { uri: 'file:///proj/file.baml' } }]
});
Defensive patterns

Strategy: validation

Validate before calling

function assertCommandArgs(command, args, expectedArity) {
  if (!Array.isArray(args) || args.length !== expectedArity) {
    throw new Error(`Command ${command} expects ${expectedArity} argument(s)`);
  }
}

Type guard

function isCommandArgsValid(args) { return Array.isArray(args) && args.every(a => a !== undefined); }

Try / catch

try {
  await client.sendRequest('workspace/executeCommand', { command, arguments: args });
} catch (e) {
  if (e.message?.startsWith('Invalid command arguments')) console.warn(`Bad args for ${command}:`, e.message);
  else throw e;
}

Prevention

When it happens

Trigger: Sending an executeCommand request with arguments that fail deserialization into the command's expected parameter type, invoking a registered command with missing or extra arguments, or passing an argument shape that changed in a newer server version.

Common situations: A client extension caches command argument formats from an older BAML LSP version; hand-rolled editor tooling sends arguments in the wrong order or as strings instead of structured values; a stale client sends commands after server reload renamed or re-typed their parameters.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


AI-assisted analysis of BoundaryML/baml@bd85ce9dee (2026-09-12). Data as JSON: /api/errors/f761ea3316b532c5. Report an issue: GitHub.