after 1.1.293 upgrade: received malformed method call from Language Server: workspace/configuration: protocol error: InvalidParams #4602
-
After pyright upgrade from 1.1.292 to 1.1.293 the vscode integration works fine, but we use pyright's as lsp server for other editors too. From the release notes v1.1.293 I couldn't understand what the issue might be I could only read about bugfixes and enhancements. Helix editor with pyright 1.1.292 works fine but exactly the same config (see helix-editor/helix Wiki) with pyright 1.1.293 one gets the following error.
We switched between pyright versions with Any ideas how to solve this? |
Beta Was this translation helpful? Give feedback.
Replies: 10 comments 9 replies
-
My guess is a change in the LSP protocol that Helix editor doesn't support yet. But our last change here was in like version 1.1.289 or so: https://github.com/microsoft/pyright/pull/4443/files Can you get more information on what exact entry in the |
Beta Was this translation helpful? Give feedback.
-
I also checked LSP repo to see when workspace/configuration protocol has changed. and it was 2 months ago (dec/2022). unless helix editor itself changed LSP client, LSP in pyright should be unchanged. I think like Rich said, we need more information to find out. by the way, LSP repo doesn't have error string |
Beta Was this translation helpful? Give feedback.
-
Mmm, maybe the issue is at helix side, but between See this short example. pyright-helix-292-293.mp4Maybe the issue is not with pyright itself but with https://github.com/RobertCraigie/pyright-python? Update: installing it via |
Beta Was this translation helpful? Give feedback.
-
so, I looked all changes between 192 and 193 (e4e08c3...ceb2a2d) and there is no LSP related changes there. I think the error message might be misleading. it might be something threw, and helix reports it as LSP errors. is there a way to get more verbose log than those simple ones? |
Beta Was this translation helpful? Give feedback.
-
It took me a while to sit again on this but finally got the output form helix for the jsonrpc requests sent to pyright and the responses he gets, see below the two sessions. But in the session with pyright 294 (or 293) after the initialize request nothing seems to come back, but that's unlikely because the vscode integration works as far as I can tell. session with pyright 292 (Click me)
session with pyright 294 (Click me)
@heejaechang how can I add debugging output for pyright so that I can see the responses being sent inside pyright?
@rchiodo what is the easisest way to do that? 😬 |
Beta Was this translation helpful? Give feedback.
-
The original error listed this:
It doesn't say which entry is invalid, it just says something is a string instead of a URL. Or maybe it's saying the value "" is an invalid value but it doesn't say which parameter. I'm guessing this is coming back from the client side in helix. So it would require changes to the helix source to see what the invalid parameter is. |
Beta Was this translation helpful? Give feedback.
-
I did some digging through // helix-lsp/src/jsonrpc.rs:164
impl Params {
pub fn parse<D>(self) -> Result<D, Error>
where
D: DeserializeOwned,
{
let value: Value = self.into();
serde_json::from_value(value)
.map_err(|err| Error::invalid_params(format!("Invalid params: {}.", err)))
}
} // helix-lsp/src/lib.rs:293
impl MethodCall {
pub fn parse(method: &str, params: jsonrpc::Params) -> Result<MethodCall> {
use lsp::request::Request;
let request = match method {
// SKIP ....
lsp::request::WorkspaceConfiguration::METHOD => {
let params: lsp::ConfigurationParams = params.parse()?;
Self::WorkspaceConfiguration(params)
}
// SKIP ...
};
Ok(request)
}
} External crate #[derive(Debug, Default, Eq, PartialEq, Clone, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct ConfigurationItem {
/// The scope to get the configuration section for.
#[serde(skip_serializing_if = "Option::is_none")]
pub scope_uri: Option<Url>,
///The configuration section asked for.
#[serde(skip_serializing_if = "Option::is_none")]
pub section: Option<String>,
}
/// Deserializes this URL from a `serde` stream.
///
/// This implementation is only available if the `serde` Cargo feature is enabled.
#[cfg(feature = "serde")]
impl<'de> serde::Deserialize<'de> for Url {
fn deserialize<D>(deserializer: D) -> Result<Url, D::Error>
where
D: serde::Deserializer<'de>,
{
use serde::de::{Error, Unexpected, Visitor};
struct UrlVisitor;
impl<'de> Visitor<'de> for UrlVisitor {
type Value = Url;
fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
formatter.write_str("a string representing an URL")
}
fn visit_str<E>(self, s: &str) -> Result<Self::Value, E>
where
E: Error,
{
Url::parse(s).map_err(|err| {
let err_s = format!("{}", err);
Error::invalid_value(Unexpected::Str(s), &err_s.as_str())
})
}
}
deserializer.deserialize_str(UrlVisitor)
}
} I need to sleep. I will look at again this later. |
Beta Was this translation helpful? Give feedback.
-
@rchiodo after modifying helix source, it seems like Helix needs to handle pyright's request The parameters of that method call seems to be:
Any other suggestions? |
Beta Was this translation helpful? Give feedback.
-
Is that message causing the problem in helix? Like it fails after that point? That message is supposed to be controlled by the client. Maybe helix can specify not to send it: |
Beta Was this translation helpful? Give feedback.
-
This was a bug on our end, apologies! helix-editor/helix#6058 It looks like pyright will hang if it does not get a reply to the The dynamic registration message is the same as #2690 (see also #1302). vscode-languageserver-node will attempt dynamic registration if the |
Beta Was this translation helpful? Give feedback.
This was a bug on our end, apologies! helix-editor/helix#6058
It looks like pyright will hang if it does not get a reply to the
workspace/configuration
request. It sends one with a blank scopeUri on 1.1.293+ (but not 1.1.292). We're currently ignoring that message because it's a malformed URI type but we should be sending an error response. That PR will send an error and that seems to fix the issue. I have not debugged where the blank scopeUri comes from though.The dynamic registration message is the same as #2690 (see also #1302). vscode-languageserver-node will attempt dynamic registration if the
workspace.workspaceFolders.changeNotifications
server capability is not set statically in …