{"record":{"id":"4e85d932f10a30a1","repo":"jdx/mise","slug":"stdin-requires-exactly-one-environment-variable","errorCode":null,"errorMessage":"--stdin requires exactly one environment variable key","messagePattern":"--stdin requires exactly one environment variable key","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cli/set.rs","lineNumber":188,"sourceCode":"            // Prompt for values if requested\n            if self.prompt {\n                let theme = crate::ui::theme::get_theme();\n                for ev in &mut env_vars {\n                    if ev.value.is_none() {\n                        let prompt_msg = format!(\"Enter value for {}\", ev.key);\n                        let value = Input::new(&prompt_msg)\n                            .password(self.age_encrypt) // Mask input if encrypting\n                            .theme(&theme)\n                            .run()?;\n                        ev.value = Some(value);\n                    }\n                }\n            }\n\n            // Read value from stdin if requested\n            if self.stdin {\n                if env_vars.len() != 1 {\n                    bail!(\"--stdin requires exactly one environment variable key\");\n                }\n                let ev = &mut env_vars[0];\n                if ev.value.is_some() {\n                    bail!(\n                        \"--stdin reads the value from stdin; do not provide a value with KEY=VALUE syntax\"\n                    );\n                }\n                let mut value = String::new();\n                std::io::stdin().read_to_string(&mut value)?;\n                // Strip a single trailing newline (matches `gh secret set` behavior)\n                if value.ends_with(\"\\r\\n\") {\n                    value.truncate(value.len() - 2);\n                } else if value.ends_with('\\n') {\n                    value.truncate(value.len() - 1);\n                }\n                ev.value = Some(value);\n            }\n","sourceCodeStart":170,"sourceCodeEnd":206,"githubUrl":"https://github.com/jdx/mise/blob/533346cc374382b41ec5ff70536252b2e96e725c/src/cli/set.rs#L170-L206","documentation":"`mise set --stdin KEY` reads the variable's value from standard input, so it accepts exactly one KEY argument (without =value). If zero or multiple keys are given, mise cannot know which variable the piped value belongs to and bails.","triggerScenarios":"`mise set --stdin` with no keys; `mise set --stdin KEY1 KEY2`; passing multiple assignments with --stdin.","commonSituations":"Scripting value injection from files/secrets managers while accidentally passing several keys; forgetting the key argument entirely.","solutions":["Pass exactly one key: `echo secret | mise set --stdin API_KEY`","Set multiple variables in separate invocations without --stdin","Omit --stdin and use KEY=VALUE form for multiple variables"],"exampleFix":"// before\nmise set --stdin KEY1 KEY2   # error\n// after\necho secret | mise set --stdin KEY1","handlingStrategy":"validation","validationCode":"[[ $# -eq 1 ]] || { echo 'usage: echo value | mise set --stdin KEY'; exit 1; }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Remember --stdin is single-key by design","Loop over keys in separate commands when setting many variables"],"tags":["cli","env","stdin"],"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"}