{"record":{"id":"640134a5a72523db","repo":"astral-sh/ruff","slug":"invalidparams-640134","errorCode":"InvalidParams","errorMessage":"No kind was given for code action","messagePattern":"No kind was given for code action","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/ruff_server/src/server/api/requests/code_action_resolve.rs","lineNumber":58,"sourceCode":"        snapshot: Self::Snapshot,\n        _client: &Client,\n        mut action: types::CodeAction,\n    ) -> Result<types::CodeAction> {\n        let snapshot = match snapshot {\n            Ok(snapshot) => snapshot,\n            Err(err) => {\n                tracing::warn!(\"Returning code action unchanged because {err}.\");\n                return Ok(action);\n            }\n        };\n\n        let query = snapshot.query();\n\n        let code_actions = SupportedCodeAction::from_kind(\n            action\n                .kind\n                .clone()\n                .ok_or(anyhow::anyhow!(\"No kind was given for code action\"))\n                .with_failure_code(ErrorCode::InvalidParams)?,\n        )\n        .collect::<Vec<_>>();\n\n        // Ensure that the code action maps to _exactly one_ supported code action\n        let [action_kind] = code_actions.as_slice() else {\n            return Err(anyhow::anyhow!(\n                \"Code action resolver did not expect code action kind {:?}\",\n                action.kind.as_ref().unwrap()\n            ))\n            .with_failure_code(ErrorCode::InvalidParams);\n        };\n\n        match action_kind {\n            SupportedCodeAction::SourceFixAll | SupportedCodeAction::SourceOrganizeImports\n                if snapshot.is_notebook_cell() =>\n            {\n                // This should never occur because we ignore generating these code actions for a","sourceCodeStart":40,"sourceCodeEnd":76,"githubUrl":"https://github.com/astral-sh/ruff/blob/26f38c119cac42e4d320ba08f09224fdec74af2c/crates/ruff_server/src/server/api/requests/code_action_resolve.rs#L40-L76","documentation":"`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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Ensure the client returns the CodeAction it received from `textDocument/codeAction` unmodified, preserving the `kind` field.","Set an explicit `kind` when constructing CodeActions programmatically in a plugin or proxy.","Check for middleware in the client (e.g. VS Code extensions) that strips unknown/null fields before resolving."],"exampleFix":"// before: resolving a hand-built action without a kind\n{ \"title\": \"Fix all\", \"data\": ... }\n// after: include the kind\n{ \"title\": \"Fix all\", \"kind\": \"source.fixAll.ruff\", \"data\": ... }","handlingStrategy":"validation","validationCode":"function canResolve(action) {\n  return typeof action.kind === 'string' && action.kind.length > 0;\n}\nif (!canResolve(action)) throw new Error('code action missing kind; cannot resolve');","typeGuard":"function hasKind(a) { return a != null && typeof a.kind === 'string' && a.kind !== ''; }","tryCatchPattern":"try {\n  const resolved = await connection.sendRequest('codeAction/resolve', action);\n} catch (e) {\n  if (String(e.message).includes('No kind was given for code action')) {\n    return action; // fall back to the unresolved action\n  }\n  throw e;\n}","preventionTips":["Never mutate or strip the `kind` field when round-tripping CodeActions.","Set explicit kinds when creating actions in plugins.","Resolve only actions you originally received from that server."],"tags":["lsp","ruff","code-action","invalid-params"],"backgroundTag":"missing-required-argument","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"}