{"record":{"id":"0eb8ffef04187798","repo":"JanDeDobbeleer/oh-my-posh","slug":"q-is-not-a-number-between-1-and-d","errorCode":null,"errorMessage":"%q is not a number between 1 and %d","messagePattern":"%q is not a number between 1 and (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/cli/ui/select.go","lineNumber":58,"sourceCode":"\tfmt.Fprintf(out, \"\\nEnter a number between 1 and %d, or press Enter to cancel: \", len(items))\n\n\treader := bufio.NewReader(in)\n\n\tline, err := reader.ReadString('\\n')\n\tif err != nil && line == \"\" {\n\t\t// EOF with nothing typed is the same intent as an empty line: the user, or the script,\n\t\t// declined to choose.\n\t\treturn 0, ErrCancelled\n\t}\n\n\tline = strings.TrimSpace(line)\n\tif line == \"\" {\n\t\treturn 0, ErrCancelled\n\t}\n\n\tchoice, err := strconv.Atoi(line)\n\tif err != nil || choice < 1 || choice > len(items) {\n\t\treturn 0, fmt.Errorf(\"%q is not a number between 1 and %d\", line, len(items))\n\t}\n\n\treturn choice - 1, nil\n}\n","sourceCodeStart":40,"sourceCodeEnd":63,"githubUrl":"https://github.com/JanDeDobbeleer/oh-my-posh/blob/0976794618c5ed95de0985dded50de1b4dc914cb/src/cli/ui/select.go#L40-L63","documentation":"The interactive `Select` helper reads a line from the user and converts it to an index. If the input is not an integer or is outside the range 1..len(items), it rejects the input with this error, echoing the raw input and the valid upper bound.","triggerScenarios":"Calling Select and the user types a non-numeric string, an empty-but-nonempty-whitespace string, 0, a negative number, or a number greater than the number of items.","commonSituations":"User typos in an interactive picker (e.g. types '5' when 3 options exist, or 'one' instead of '1'); piping non-numeric input into a prompt-driven command in scripts/CI.","solutions":["Enter a number between 1 and the number of listed options","Press Enter on an empty line to cancel (returns ErrCancelled) instead of typing invalid input","In scripts, pipe valid numeric input or avoid the interactive prompt entirely (e.g. use non-interactive flags)"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"n, err := strconv.Atoi(line)\nif err != nil || n < 1 || n > len(items) {\n    // reprompt the user before calling Select, or default to a valid choice\n}","typeGuard":null,"tryCatchPattern":"choice, err := ui.Select(question, items)\nif err != nil {\n    if errors.Is(err, ui.ErrCancelled) { return nil }\n    // invalid choice: reprompt in a loop\n}","preventionTips":["Loop on the prompt until a valid number or empty line is entered","Show the valid range (1..N) in the prompt text","In scripts, feed explicit valid numbers or run in non-interactive mode"],"tags":["cli","interactive-prompt","input-validation"],"backgroundTag":"invalid-user-input","analyzedSha":"0976794618c5ed95de0985dded50de1b4dc914cb","analyzedAt":"2026-08-31T23:41:19.708Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}