Return code action for codeAction/resolve requests that contain no or no valid URL#25365
Conversation
dd70a47 to
93632f1
Compare
|
codeAction/resolve requests
| .data | ||
| .clone() | ||
| .ok_or_else(|| anyhow::anyhow!("Code action is missing its document URI")) | ||
| .with_failure_code(ErrorCode::InvalidParams)?; |
There was a problem hiding this comment.
I'm not entirely sure whether answering here with InvalidParams is correct. Because the parameters for codeAction/resolve are correct. It's just that our background handler can't resolve any code actions without an URL. But this is more a Ruff requirement than a LSP requirement.
In ty_server, we have a BackgroundRequestHandler that does not do the document lookup for you, and, therefore, allows to customize the response when the url field is missing. Could we add something similar to ruff_server?
There was a problem hiding this comment.
Thanks, that makes sense. I pushed an update that moves codeAction/resolve off the shared document-request path and gives it its own background preparation step instead, similar to ty_server.
codeAction/resolve requestscodeAction/resolve requests that contain no or no valid URL
|
I unified the |
39e5574 to
849351b
Compare
…or no valid URL (astral-sh#25365) Co-authored-by: Micha Reiser <[email protected]>
Closes #25364.
Summary
Handle invalid
codeAction/resolvedocument URIs before scheduling a background request.This changes the background document request path to extract document URLs fallibly and return an
InvalidParamsresponse when the request payload is malformed, instead of panicking while preparing the task. ForCodeActionResolve, missing or invalidCodeAction.datais now reported as an invalid document URI.Test Plan
Added integration tests