{"record":{"id":"ba9365b547d21f80","repo":"jdx/mise","slug":"expected-y-yes-or-n-no-got","errorCode":null,"errorMessage":"expected y/yes or n/no, got {:?}","messagePattern":"expected y/yes or n/no, got (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/ui/prompt.rs","lineNumber":146,"sourceCode":"fn parse_confirm_answer(line: Option<&str>, default_yes: bool) -> eyre::Result<Confirmation> {\n    let Some(line) = line else {\n        // A decline, not `Unavailable`: the question *was* put on stderr and\n        // stdin ended without an answer, so nothing was consented to.\n        // `Unavailable` is reserved for the question never reaching anyone.\n        // Keeping it a decline is also what every caller already assumed, and\n        // leaves silence safe to read as \"no\" for any that come later.\n        return Ok(Confirmation::No);\n    };\n    let answer = line.trim().to_lowercase();\n    if answer.is_empty() {\n        return Ok(default_answer(default_yes));\n    }\n    if \"yes\".starts_with(&answer) {\n        Ok(Confirmation::Yes)\n    } else if \"no\".starts_with(&answer) {\n        Ok(Confirmation::No)\n    } else {\n        eyre::bail!(\"expected y/yes or n/no, got {:?}\", line.trim())\n    }\n}\n\nfn default_answer(default_yes: bool) -> Confirmation {\n    if default_yes {\n        Confirmation::Yes\n    } else {\n        Confirmation::No\n    }\n}\n\npub(crate) fn confirm_with_all<S: Into<String>>(message: S) -> eyre::Result<Confirmation> {\n    let _lock = MUTEX.lock().unwrap(); // Prevent multiple prompts at once\n    ctrlc::show_cursor_after_ctrl_c();\n\n    if !can_prompt_dialog() {\n        return Ok(Confirmation::Unavailable);\n    }","sourceCodeStart":128,"sourceCodeEnd":164,"githubUrl":"https://github.com/jdx/mise/blob/afd2eddd3a50c16190efc1c7e94404b48f72af57/src/ui/prompt.rs#L128-L164","documentation":"parse_confirm_answer accepts only prefixes of \"yes\"/\"no\" (including \"y\"/\"n\"); any other answer to an interactive confirmation prompt causes this error. It is reached via read_confirm_from_stdin when mise prompts the user (e.g. trust or install confirmations).","triggerScenarios":"Typing anything other than y/yes/n/no (case-insensitive prefixes) at a mise [Y/n] prompt, e.g. \"ok\", \"1\", an empty-but-nonmatching line, or piped input containing other text.","commonSituations":"Non-interactive shells piping unexpected text into mise (CI scripts, `echo foo | mise ...`), fat-fingering the prompt, or automation wrapping mise and feeding it unanticipated answers.","solutions":["Answer with y, yes, n, or no at the prompt.","When non-interactive, bypass the prompt with the appropriate flag (e.g. `mise trust --all`, `yes | ...` is fragile — prefer explicit flags).","If piping scripted input, ensure the line is exactly y/yes/n/no with no extra tokens on the same line."],"exampleFix":"// before (script)\necho ok | mise trust\n// after\nmise trust --all","handlingStrategy":"fallback","validationCode":"// For scripted answers, only feed exact accepted values:\nconst answer = 'y';\nif (!['y', 'yes', 'n', 'no'].includes(answer.toLowerCase())) throw new Error(`bad prompt answer: ${answer}`);","typeGuard":"function isConfirmAnswer(v) { return ['y','yes','n','no'].includes(String(v).trim().toLowerCase()); }","tryCatchPattern":"try {\n  run('mise trust');\n} catch (e) {\n  if (/expected y\\/yes or n\\/no/.test(String(e))) {\n    run('mise trust --all'); // non-interactive path\n  } else throw e;\n}","preventionTips":["Use explicit non-interactive flags in scripts/CI instead of piping prompt answers.","Never pipe arbitrary text into mise commands that prompt.","Document accepted answers (y/yes/n/no) for any automation that wraps prompts."],"tags":["cli","prompt","input-validation","interactive"],"backgroundTag":"invalid-argument-value","analyzedSha":"afd2eddd3a50c16190efc1c7e94404b48f72af57","analyzedAt":"2026-09-09T01:38:25.179Z","contentChangedAt":"2026-09-09T01:38:25.179Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}