JanDeDobbeleer/oh-my-posh · warning
%q is not a number between 1 and %d
Error message
%q is not a number between 1 and %d
What it means
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.
Source
Thrown at src/cli/ui/select.go:58
fmt.Fprintf(out, "\nEnter a number between 1 and %d, or press Enter to cancel: ", len(items))
reader := bufio.NewReader(in)
line, err := reader.ReadString('\n')
if err != nil && line == "" {
// EOF with nothing typed is the same intent as an empty line: the user, or the script,
// declined to choose.
return 0, ErrCancelled
}
line = strings.TrimSpace(line)
if line == "" {
return 0, ErrCancelled
}
choice, err := strconv.Atoi(line)
if err != nil || choice < 1 || choice > len(items) {
return 0, fmt.Errorf("%q is not a number between 1 and %d", line, len(items))
}
return choice - 1, nil
}
View on GitHub (pinned to 0976794618)
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)
Defensive patterns
Strategy: validation
Validate before calling
n, err := strconv.Atoi(line)
if err != nil || n < 1 || n > len(items) {
// reprompt the user before calling Select, or default to a valid choice
} Try / catch
choice, err := ui.Select(question, items)
if err != nil {
if errors.Is(err, ui.ErrCancelled) { return nil }
// invalid choice: reprompt in a loop
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- invalid export format
- --data-only and --data-derive contradict each other: one for
- font path must be a valid URL
- no assets found
- we do not have permissions to update
AI-assisted analysis of JanDeDobbeleer/oh-my-posh@0976794618 (2026-08-31).
Data as JSON: /api/errors/0eb8ffef04187798.
Report an issue: GitHub.