{"record":{"id":"54ea39862c7c9429","repo":"rust-lang/rust-analyzer","slug":"unable-to-serialize-args","errorCode":null,"errorMessage":"Unable to serialize args","messagePattern":"Unable to serialize args","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/rust-analyzer/src/discover.rs","lineNumber":58,"sourceCode":"    /// Create a new [DiscoverCommand].\n    pub(crate) fn new(sender: Sender<DiscoverProjectMessage>, command: Vec<String>) -> Self {\n        Self { sender, command }\n    }\n\n    /// Spawn the command inside `DiscoverCommand` and report progress, if any.\n    pub(crate) fn spawn(\n        &self,\n        discover_arg: DiscoverArgument,\n        current_dir: &Path,\n    ) -> anyhow::Result<DiscoverHandle> {\n        let command = &self.command[0];\n        let args = &self.command[1..];\n\n        let args: Vec<String> = args\n            .iter()\n            .map(|arg| {\n                if arg == ARG_PLACEHOLDER {\n                    serde_json::to_string(&discover_arg).expect(\"Unable to serialize args\")\n                } else {\n                    arg.to_owned()\n                }\n            })\n            .collect();\n\n        // TODO: are we sure the extra env should be empty?\n        let mut cmd = toolchain::command(command, current_dir, &FxHashMap::default());\n        cmd.args(args);\n\n        Ok(DiscoverHandle {\n            handle: CommandHandle::spawn(cmd, DiscoverProjectParser, self.sender.clone(), None)?,\n            span: info_span!(\"discover_command\").entered(),\n        })\n    }\n}\n\n/// A handle to a spawned `DiscoverCommand`.","sourceCodeStart":40,"sourceCodeEnd":76,"githubUrl":"https://github.com/rust-lang/rust-analyzer/blob/e8f7e90aa3e7b26aa9a000200f606c1078da99ec/crates/rust-analyzer/src/discover.rs#L40-L76","documentation":"An `anyhow` error produced in `DiscoverCommand::spawn` while serializing the substituted discover-command arguments to JSON for the child process: one of the arguments templated into the command line failed to serialize. It is a guard around serde serialization of user-configured strings/paths; the input at fault is the `discover` command configuration being passed to the spawned process.","triggerScenarios":"Thrown at crates/rust-analyzer/src/discover.rs:58 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Validate the `discover` command arguments in configuration (non-UTF8 paths or unsupported placeholder values)","Check that the argument being templated (`{ARG_PLACEHOLDER}`-substituted) serializes as a plain JSON string","Log the offending argument when serialization fails so the misconfigured entry can be identified"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"e8f7e90aa3e7b26aa9a000200f606c1078da99ec","analyzedAt":"2026-09-03T21:08:06.959Z","contentChangedAt":"2026-09-03T21:08:06.959Z","schemaVersion":2},"datasetVersion":"2026-09-11T07:07:21.782Z"}