helix-editor/helix · error · anyhow::Error
failed to parse arguments: {err}
Error message
failed to parse arguments: {err} What it means
`:lsp-workspace-command <command> [args...]` forwards arguments to workspace/executeCommand. Every remaining prompt word is deserialized as a JSON value using a serde_json stream (Deserializer::from_str(..).into_iter()), so each word must itself be valid JSON — a bare string, number, array, or object. A word that fails JSON parsing aborts with 'failed to parse arguments: <err>' before the request is sent.
Source
Thrown at helix-term/src/commands/typed.rs:1773
));
Ok(call)
};
cx.jobs.callback(callback);
} else {
let command = args[0].to_string();
let matches: Vec<_> = ls_id_commands
.filter(|(_ls_id, c)| *c == &command)
.collect();
match matches.as_slice() {
[(ls_id, _command)] => {
let arguments = args
.get(1)
.map(|rest| {
serde_json::Deserializer::from_str(rest)
.into_iter()
.collect::<Result<Vec<Value>, _>>()
.map_err(|err| anyhow!("failed to parse arguments: {err}"))
})
.transpose()?
.filter(|args| !args.is_empty());
cx.editor.execute_lsp_command(
helix_lsp::lsp::Command {
title: command.clone(),
arguments,
command,
},
*ls_id,
);
}
[] => {
cx.editor.set_status(format!(
"`{command}` is not supported for any language server"
));
}View on GitHub (pinned to 079a789e8c)
Solutions
- Pass each argument as valid JSON: numbers bare (3), strings double-quoted ("hello"), objects/arrays as-is ('{"k":1}').
- Omit all arguments to open the picker of commands the server actually advertises.
- Check the command name too — it must exactly match one advertised by an attached server.
Example fix
# before :lsp-workspace-command myCommand hello # after :lsp-workspace-command myCommand "hello"
Defensive patterns
Strategy: validation
Validate before calling
// each argument word must be a standalone JSON value
fn args_ok(words: &[String]) -> bool {
words.iter().all(|w| serde_json::from_str::<serde_json::Value>(w).is_ok())
} Prevention
- Quote string arguments as JSON ('"hello"', not hello) when scripting :lsp-workspace-command.
- Use the no-argument form to enumerate the exact commands a server advertises.
When it happens
Trigger: `:lsp-workspace-command rust-analyzer.reloadWorkspace notjson`; passing an unquoted word ('hello'); an object with unbalanced braces or smart quotes pasted from rendered docs.
Common situations: Expecting shell-style bare-string arguments; quoting confusion in the prompt; copy-paste introducing curly quotes; forgetting that strings must be double-quoted.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- Failed to parse snippet. Remaining input: {}
- Language server '{name}' not defined
- No previous working directory
- Could not change working directory to '{}': {err}
- Error restarting language servers: {}
AI-assisted analysis of helix-editor/helix@079a789e8c (2026-08-16).
Data as JSON: /api/errors/9066a5d8c4fd9568.
Report an issue: GitHub.