astral-sh/ruff · error

InvalidParams

InvalidParams

Error message

Invalid command `{name}`

What it means

The LSP server received a workspace/executeCommand request whose `command` string does not match any SupportedCommand. FromStr for SupportedCommand (capabilities.rs) only accepts "ty.printDebugInformation"; anything else is rejected with error code InvalidParams.

Source

Thrown at crates/ty_server/src/capabilities.rs:79

    const fn identifier(self) -> &'static str {
        match self {
            SupportedCommand::Debug => "ty.printDebugInformation",
        }
    }

    /// Returns all the commands that the server currently supports.
    const fn all() -> [SupportedCommand; 1] {
        [SupportedCommand::Debug]
    }
}

impl FromStr for SupportedCommand {
    type Err = anyhow::Error;

    fn from_str(name: &str) -> anyhow::Result<Self, Self::Err> {
        Ok(match name {
            "ty.printDebugInformation" => Self::Debug,
            _ => return Err(anyhow::anyhow!("Invalid command `{name}`")),
        })
    }
}

/// Returns the preferred markup kind, derived from preference list.
fn preferred_markup_kind(formats: &[MarkupKind]) -> Option<&MarkupKind> {
    formats
        .iter()
        .find(|markup_kind| matches!(markup_kind, MarkupKind::Markdown | MarkupKind::PlainText))
}

impl ResolvedClientCapabilities {
    /// Returns `true` if the client supports workspace diagnostic refresh.
    pub(crate) const fn supports_workspace_diagnostic_refresh(self) -> bool {
        self.contains(Self::WORKSPACE_DIAGNOSTIC_REFRESH)
    }

    /// Returns `true` if the client supports workspace configuration.

View on GitHub (pinned to 672bb4edf0)

Solutions

  1. Use the exact string "ty.printDebugInformation"
  2. Check the `commands` list advertised in the server's initialize result before invoking
  3. Update the ty server and the client extension to matching versions
  4. Remove the stale keybinding/extension that sends the unknown command

Example fix

// before
client.sendRequest('workspace/executeCommand', { command: 'ty.debugInfo' });

// after
client.sendRequest('workspace/executeCommand', { command: 'ty.printDebugInformation' });
Defensive patterns

Strategy: validation

Validate before calling

// TS: check against the server's advertised commands before invoking
const serverCommands: string[] = initResult.capabilities.executeCommandProvider?.commands ?? [];
if (serverCommands.includes(name)) {
  await client.sendRequest('workspace/executeCommand', { command: name });
} else {
  log.warn(`command ${name} not supported by ty server`);
}

Type guard

const isSupportedCommand = (name: string): boolean =>
  name === 'ty.printDebugInformation';

Prevention

When it happens

Trigger: Sending workspace/executeCommand with a command name other than "ty.printDebugInformation" — e.g. a command from a different tool, a renamed command, or a client extension invoking a command this server version does not register.

Common situations: Editor extension and ty server version mismatch (command renamed/added later), commands left over from a fork or older protocol, or a hand-rolled LSP client hardcoding the wrong string.

Related errors


AI-assisted analysis of astral-sh/ruff@672bb4edf0 (2026-08-16). Data as JSON: /api/errors/a824f51cd00ad734. Report an issue: GitHub.