{"record":{"id":"f761ea3316b532c5","repo":"BoundaryML/baml","slug":"invalid-command-arguments-for-command-command-message","errorCode":null,"errorMessage":"Invalid command arguments for command: {command}: {message}","messagePattern":"Invalid command arguments for command: (.+?): (.+?)","errorType":"error_code","errorClass":"LspError","httpStatus":null,"severity":"error","filePath":"baml_language/crates/baml_lsp/src/error.rs","lineNumber":31,"sourceCode":"    #[error(\"Notification not supported: {0}\")]\n    NotificationNotSupported(String),\n    #[error(\"{0}\")]\n    RequestExtractError(lsp_server::ExtractError<lsp_server::Request>),\n    #[error(\"Request not supported: {0}\")]\n    RequestNotSupported(String),\n    #[error(\"Failed to serialize request result: {0}\")]\n    RequestSerializeError(serde_json::Error),\n    /// The client's sink is gone; nothing more can be delivered.\n    #[error(\"Client closed\")]\n    ClientClosed,\n    /// Bounded transport backpressure (LSP `RequestFailed`, `-32803`).\n    #[error(\"LSP outbound sink is saturated\")]\n    OutboundSaturated,\n    /// A frame larger than the transport limit (LSP `RequestFailed`,\n    /// `-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`).","sourceCodeStart":13,"sourceCodeEnd":49,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/baml_language/crates/baml_lsp/src/error.rs#L13-L49","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Log the command name and arguments on the client side and compare against the command's expected parameter signature in baml_lsp.","Update the client extension/tooling to match the server's current command argument schema.","Ensure arguments are JSON-serializable values of the exact expected types (numbers as numbers, positions as {line, character}, etc.).","Re-run the LSP initialize handshake so the client picks up the server's current command registrations."],"exampleFix":"// before\nclient.sendRequest('workspace/executeCommand', {\n  command: 'baml.generate',\n  arguments: [\"file.baml\"]\n});\n// after\nclient.sendRequest('workspace/executeCommand', {\n  command: 'baml.generate',\n  arguments: [{ textDocument: { uri: 'file:///proj/file.baml' } }]\n});","handlingStrategy":"validation","validationCode":"function assertCommandArgs(command, args, expectedArity) {\n  if (!Array.isArray(args) || args.length !== expectedArity) {\n    throw new Error(`Command ${command} expects ${expectedArity} argument(s)`);\n  }\n}","typeGuard":"function isCommandArgsValid(args) { return Array.isArray(args) && args.every(a => a !== undefined); }","tryCatchPattern":"try {\n  await client.sendRequest('workspace/executeCommand', { command, arguments: args });\n} catch (e) {\n  if (e.message?.startsWith('Invalid command arguments')) console.warn(`Bad args for ${command}:`, e.message);\n  else throw e;\n}","preventionTips":["Keep client command invocations in a single module mirroring the server's command signatures","Validate argument shape before every executeCommand call","Update client tooling in lockstep with server version bumps"],"tags":["lsp","json-rpc","arguments","serialization"],"backgroundTag":"invalid-argument-value","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"}