{"record":{"id":"4275769b3a249a7c","repo":"astral-sh/ruff","slug":"invalid-command-name","errorCode":null,"errorMessage":"Invalid command `{name}`","messagePattern":"Invalid command `(.+?)`","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"crates/ruff_server/src/server.rs","lineNumber":368,"sourceCode":"        [\n            SupportedCommand::Format,\n            SupportedCommand::FixAll,\n            SupportedCommand::OrganizeImports,\n            SupportedCommand::Debug,\n        ]\n    }\n}\n\nimpl FromStr for SupportedCommand {\n    type Err = anyhow::Error;\n\n    fn from_str(name: &str) -> anyhow::Result<Self, Self::Err> {\n        Ok(match name {\n            \"ruff.applyAutofix\" => Self::FixAll,\n            \"ruff.applyFormat\" => Self::Format,\n            \"ruff.applyOrganizeImports\" => Self::OrganizeImports,\n            \"ruff.printDebugInformation\" => Self::Debug,\n            _ => return Err(anyhow::anyhow!(\"Invalid command `{name}`\")),\n        })\n    }\n}\n\ntype PanicHook = Box<dyn Fn(&PanicHookInfo<'_>) + 'static + Sync + Send>;\n\nstruct ServerPanicHookHandler {\n    hook: Option<PanicHook>,\n    // Hold on to the strong reference for as long as the panic hook is set.\n    _client: Arc<Client>,\n}\n\nimpl ServerPanicHookHandler {\n    fn new(client: Client) -> Self {\n        let hook = std::panic::take_hook();\n        let client = Arc::new(client);\n\n        // Use a weak reference to the client because it must be dropped when exiting or the","sourceCodeStart":350,"sourceCodeEnd":386,"githubUrl":"https://github.com/astral-sh/ruff/blob/26f38c119cac42e4d320ba08f09224fdec74af2c/crates/ruff_server/src/server.rs#L350-L386","documentation":"The server parses incoming `workspace/executeCommand` names into a `Command` enum via `from_str`. Any command string other than the four supported ones (applyAutofix, applyFormat, applyOrganizeImports, printDebugInformation) produces this anyhow error, which surfaces as a request failure to the client.","triggerScenarios":"Client sends `workspace/executeCommand` with a name like `ruff.applyRuleFix`, a typo (`ruff.applyautoFix`), or a command registered by another extension but routed to Ruff.","commonSituations":"Editor integrations hardcoding command names from an older Ruff server version; users binding a keybinding to a renamed command; other language servers' commands invoked in a file where Ruff is the active server.","solutions":["Use one of the exact supported commands: ruff.applyAutofix, ruff.applyFormat, ruff.applyOrganizeImports, ruff.printDebugInformation","Check the client/plugin version matches the Ruff server version and update both","Inspect `client -> server` logs to confirm the exact command string casing","If you need a new command, add it to the Command enum and its match arm in the server"],"exampleFix":"// before\nexecuteCommand('ruff.applyFixAll')\n// after\nexecuteCommand('ruff.applyAutofix')","handlingStrategy":"validation","validationCode":"// Client-side whitelist before executeCommand\nconst RUFF_COMMANDS = new Set([\n  'ruff.applyAutofix', 'ruff.applyFormat',\n  'ruff.applyOrganizeImports', 'ruff.printDebugInformation',\n]);\nif (!RUFF_COMMANDS.has(command)) throw new Error(`unsupported: ${command}`);","typeGuard":null,"tryCatchPattern":"// TypeScript\ntry {\n  await commands.executeCommand('ruff.applyAutofix');\n} catch (e) {\n  if (String(e.message).includes('Invalid command')) {\n    console.warn('Command not supported by this Ruff server version');\n  } else throw e;\n}","preventionTips":["Copy command names exactly from the Ruff server's registered capabilities","Derive command names from the server's advertised list instead of hardcoding","Re-check command names when upgrading Ruff versions","Namespace custom commands distinctly from ruff.* to avoid collisions"],"tags":["rust","lsp","server","command"],"backgroundTag":"unknown-lsp-command","analyzedSha":"26f38c119cac42e4d320ba08f09224fdec74af2c","analyzedAt":"2026-09-05T10:32:37.492Z","contentChangedAt":"2026-09-05T10:32:37.492Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}