{"record":{"id":"67dd16868fb180a7","repo":"jdx/mise","slug":"tool-option-requires-a-non-empty-key","errorCode":null,"errorMessage":"--tool-option requires a non-empty key","messagePattern":"--tool-option requires a non-empty key","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cli/use.rs","lineNumber":198,"sourceCode":"    }\n\n    fn request_options(&self) -> Result<ToolVersionOptions> {\n        let mut options = ToolVersionOptions::default();\n        let mut entries = Vec::new();\n        if let Some(command) = &self.postinstall {\n            entries.push((\n                \"postinstall\".to_string(),\n                toml::Value::String(command.clone()),\n                \"--postinstall\",\n            ));\n        }\n        for option in &self.tool_option {\n            let (key, value) = option\n                .split_once('=')\n                .ok_or_else(|| eyre!(\"--tool-option expects KEY=VALUE: {option}\"))?;\n            let key = key.trim();\n            if key.is_empty() {\n                bail!(\"--tool-option requires a non-empty key\");\n            }\n            let value = toml::from_str::<toml::Table>(&format!(\"value = {value}\"))\n                .ok()\n                .filter(|table| table.len() == 1)\n                .and_then(|mut table| table.remove(\"value\"))\n                .unwrap_or_else(|| toml::Value::String(value.to_string()));\n            entries.push((key.to_string(), value, \"--tool-option\"));\n        }\n        let mut seen = std::collections::HashSet::new();\n        for (key, value, flag) in entries {\n            if !seen.insert(key.clone()) {\n                bail!(\n                    \"tool option {key:?} was specified more than once for {}\",\n                    self.tool\n                );\n            }\n            if self\n                .tool","sourceCodeStart":180,"sourceCodeEnd":216,"githubUrl":"https://github.com/jdx/mise/blob/533346cc374382b41ec5ff70536252b2e96e725c/src/cli/use.rs#L180-L216","documentation":"`mise use --tool-option` parses each occurrence as KEY=VALUE. An occurrence whose key part (before '=') is empty — e.g. `--tool-option =foo` or `--tool-option \" =foo\"` — is rejected because an option with no name cannot be recorded.","triggerScenarios":"Passing `--tool-option \"=value\"` or `--tool-option \" =value\"` via CLI, or a flag built from a shell variable that expanded to an empty key.","commonSituations":"Shell variable interpolation yielding an empty key (OPT=\"\"; mise use --tool-option \"$OPT=1\"); hand-edited scripts dropping the key; copy-paste of flags losing the key before '='.","solutions":["Provide KEY=VALUE with a non-empty key: --tool-option verbose=true","Quote the whole argument so the shell does not split or drop parts: --tool-option \"key=value\"","Check the variable feeding the flag: echo \"[$OPT]\" to see the actual expansion"],"exampleFix":"// before\nmise use --tool-option \"=true\" node\n// after\nmise use --tool-option \"verbose=true\" node","handlingStrategy":"validation","validationCode":"for (const opt of toolOptions) {\n  const i = opt.indexOf('=');\n  if (i <= 0 || !opt.slice(0,i).trim()) throw new Error(`--tool-option needs KEY=VALUE, got: ${opt}`);\n}","typeGuard":"const isValidToolOption = (s: string): s is `${string}=${string}` => {\n  const i = s.indexOf('=');\n  return i > 0 && s.slice(0, i).trim().length > 0;\n};","tryCatchPattern":"try { exec(`mise use ${flags} ${tool}`); } catch (e) { if (String(e).includes('non-empty key')) console.error('each --tool-option must be KEY=VALUE with a non-empty KEY'); throw e; }","preventionTips":["Always quote --tool-option arguments in shell","Assert shell variables feeding keys are non-empty before building the command","Keep option flags in one place (config file) to avoid hand-built flag strings"],"tags":["cli","tool-options","validation"],"backgroundTag":"invalid-cli-argument","analyzedSha":"533346cc374382b41ec5ff70536252b2e96e725c","analyzedAt":"2026-09-17T13:35:38.149Z","contentChangedAt":"2026-09-17T13:35:38.149Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}