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

  1. Pass each argument as valid JSON: numbers bare (3), strings double-quoted ("hello"), objects/arrays as-is ('{"k":1}').
  2. Omit all arguments to open the picker of commands the server actually advertises.
  3. 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

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

Related errors


AI-assisted analysis of helix-editor/helix@079a789e8c (2026-08-16). Data as JSON: /api/errors/9066a5d8c4fd9568. Report an issue: GitHub.