astral-sh/ruff · error

InvalidParams

InvalidParams

Error message

No kind was given for code action

What it means

`codeAction/resolve` requires the original CodeAction to carry a `kind` (e.g. quickfix, source.fixAll). Ruff uses the kind to map the action to its supported resolver; if `action.kind` is None it cannot dispatch, so it rejects the request with InvalidParams per the LSP spec.

Source

Thrown at crates/ruff_server/src/server/api/requests/code_action_resolve.rs:58

        snapshot: Self::Snapshot,
        _client: &Client,
        mut action: types::CodeAction,
    ) -> Result<types::CodeAction> {
        let snapshot = match snapshot {
            Ok(snapshot) => snapshot,
            Err(err) => {
                tracing::warn!("Returning code action unchanged because {err}.");
                return Ok(action);
            }
        };

        let query = snapshot.query();

        let code_actions = SupportedCodeAction::from_kind(
            action
                .kind
                .clone()
                .ok_or(anyhow::anyhow!("No kind was given for code action"))
                .with_failure_code(ErrorCode::InvalidParams)?,
        )
        .collect::<Vec<_>>();

        // Ensure that the code action maps to _exactly one_ supported code action
        let [action_kind] = code_actions.as_slice() else {
            return Err(anyhow::anyhow!(
                "Code action resolver did not expect code action kind {:?}",
                action.kind.as_ref().unwrap()
            ))
            .with_failure_code(ErrorCode::InvalidParams);
        };

        match action_kind {
            SupportedCodeAction::SourceFixAll | SupportedCodeAction::SourceOrganizeImports
                if snapshot.is_notebook_cell() =>
            {
                // This should never occur because we ignore generating these code actions for a

View on GitHub (pinned to 26f38c119c)

Solutions

  1. Ensure the client returns the CodeAction it received from `textDocument/codeAction` unmodified, preserving the `kind` field.
  2. Set an explicit `kind` when constructing CodeActions programmatically in a plugin or proxy.
  3. Check for middleware in the client (e.g. VS Code extensions) that strips unknown/null fields before resolving.

Example fix

// before: resolving a hand-built action without a kind
{ "title": "Fix all", "data": ... }
// after: include the kind
{ "title": "Fix all", "kind": "source.fixAll.ruff", "data": ... }
Defensive patterns

Strategy: validation

Validate before calling

function canResolve(action) {
  return typeof action.kind === 'string' && action.kind.length > 0;
}
if (!canResolve(action)) throw new Error('code action missing kind; cannot resolve');

Type guard

function hasKind(a) { return a != null && typeof a.kind === 'string' && a.kind !== ''; }

Try / catch

try {
  const resolved = await connection.sendRequest('codeAction/resolve', action);
} catch (e) {
  if (String(e.message).includes('No kind was given for code action')) {
    return action; // fall back to the unresolved action
  }
  throw e;
}

Prevention

When it happens

Trigger: A client sends codeAction/resolve for a CodeAction whose `kind` field is missing/null — typically a client that stripped the kind when round-tripping the action, or a custom/proxy client constructing CodeActions itself.

Common situations: Editor plugins that serialize/deserialize code actions and drop null fields, LSP middleware that mutates the action, or tests hand-crafting a CodeAction without kind.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of astral-sh/ruff@26f38c119c (2026-09-05). Data as JSON: /api/errors/640134a5a72523db. Report an issue: GitHub.