kovidgoyal/kitty · warning

Invalid number for {func}: {rest}

Error message

Invalid number for {func}: {rest}

What it means

An integer-requiring action (nth_os_window, nth_window, visual_window_select_action_trigger, next_layout) got a non-numeric argument; kitty falls back to 1. Empty rest is silently treated as 1 without logging.

Source

Thrown at kitty/options/utils.py:368

        log_error('Too few arguments to remote_control function')
    return func, args


@func_with_args('remote_control_script')
def remote_control_script(func: str, rest: str) -> FuncArgsType:
    func, args = shlex_parse(func, rest)
    if len(args) < 1:
        log_error('Too few arguments to remote_control_script function')
    return func, args


@func_with_args('nth_os_window', 'nth_window', 'visual_window_select_action_trigger', 'next_layout')
def single_integer_arg(func: str, rest: str) -> FuncArgsType:
    try:
        num = int(rest)
    except Exception:
        if rest:
            log_error(f'Invalid number for {func}: {rest}')
        num = 1
    return func, [num]


@func_with_args('scroll_to_prompt')
def scroll_to_prompt(func: str, rest: str) -> FuncArgsType:
    vals = rest.strip().split()
    args = [-1, 0]
    if len(vals) > 2:
        log_error('scroll_to_prompt needs one or two arguments, using defaults')
    else:
        try:
            args[0] = int(vals[0])
        except Exception:
            log_error(f'{vals[0]} is not a valid number of prompts to jump for scroll_to_prompt')
        if len(vals) == 2:
            try:
                args[1] = int(vals[1])

View on GitHub (pinned to 6d5d0c4406)

Solutions

  1. Use a plain integer, e.g. `map f1 nth_window 3`
  2. Remove suffixes/words from the numeric argument

Example fix

# before
map f1 nth_window 2nd
# after
map f1 nth_window 2
Defensive patterns

Strategy: validation

Validate before calling

ok = '3'.lstrip('+-').isdigit()

Prevention

When it happens

Trigger: `map f1 nth_window first` — int(rest) raises ValueError because the token isn't numeric.

Common situations: Writing ordinals or words instead of numbers; stray characters like '2nd' or '#2'.

Understand the failure class

Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.

Related errors


AI-assisted analysis of kovidgoyal/kitty@6d5d0c4406 (2026-08-27). Data as JSON: /api/errors/e55942a62e997013. Report an issue: GitHub.