Skip to content

ruff server: codeAction/resolve with missing or malformed data crashes the server #25364

@fallintoplace

Description

@fallintoplace

Summary

ruff server assumes that every codeAction/resolve request contains a valid document URI in CodeAction.data.

If data is missing, null, not a URL string, or an invalid URL string, the server panics while preparing the background task and exits instead of returning InvalidParams.

I reproduced this on current main after a normal initialize request by sending:

{
  "jsonrpc": "2.0",
  "id": 2,
  "method": "codeAction/resolve",
  "params": {
    "title": "Ruff: Fix all auto-fixable problems",
    "kind": "source.fixAll.ruff"
  }
}

These variants also crash:

  • "data": null
  • "data": {"uri": "file:///tmp/x.py"}
  • "data": "not-a-url"

Observed result:

  • ruff server exits with status 101
  • stderr shows a panic from crates/ruff_server/src/server/api/requests/code_action_resolve.rs

The root cause appears to be:

  • CodeActionResolve::document_url deserializes params.data.clone().unwrap_or_default() and calls expect(...)
  • this happens during background task setup in background_request_task, before the request-level catch_unwind
  • the panic then propagates out of the main loop thread and exits the server

Expected result:
Malformed codeAction/resolve input should return InvalidParams instead of panicking or exiting the server.

One additional note: ruff server advertises codeActionProvider.resolveProvider = true unconditionally. I have not confirmed that a mainstream editor hits this path on its own, but a malformed codeAction/resolve request currently crashes the server.

Version

ruff 0.15.14

Source checkout: 0909c7ec2159 (main on 2026-05-23)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingserverRelated to the LSP server

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions