kovidgoyal/kitty · error

Invalid size specification: %s

Error message

Invalid size specification: %s

What it means

The icat kitten was invoked with --use-window-size whose value must be a comma-separated list of exactly 4 numbers (columns,rows,xpixel,ypixel). The string split on ',' did not yield 4 parts, so the size spec is rejected.

Source

Thrown at kittens/icat/main.go:195

		return 1, err
	}
	if opts.UseWindowSize == "" {
		if tty.IsTerminal(os.Stdout.Fd()) {
			screen_size, err = tty.GetSize(int(os.Stdout.Fd()))
		} else {
			t, oerr := tty.OpenControllingTerm()
			if oerr != nil {
				return 1, fmt.Errorf("Failed to open controlling terminal with error: %w", oerr)
			}
			screen_size, err = t.GetSize()
		}
		if err != nil {
			return 1, fmt.Errorf("Failed to query terminal using TIOCGWINSZ with error: %w", err)
		}
	} else {
		parts := strings.SplitN(opts.UseWindowSize, ",", 4)
		if len(parts) != 4 {
			return 1, fmt.Errorf("Invalid size specification: %s", opts.UseWindowSize)
		}
		screen_size = &unix.Winsize{}
		var t uint64
		if t, err = strconv.ParseUint(parts[0], 10, 16); err != nil || t < 1 {
			return 1, fmt.Errorf("Invalid size specification: %s with error: %w", opts.UseWindowSize, err)
		}
		screen_size.Col = uint16(t)
		if t, err = strconv.ParseUint(parts[1], 10, 16); err != nil || t < 1 {
			return 1, fmt.Errorf("Invalid size specification: %s with error: %w", opts.UseWindowSize, err)
		}
		screen_size.Row = uint16(t)
		if t, err = strconv.ParseUint(parts[2], 10, 16); err != nil || t < 1 {
			return 1, fmt.Errorf("Invalid size specification: %s with error: %w", opts.UseWindowSize, err)
		}
		screen_size.Xpixel = uint16(t)
		if t, err = strconv.ParseUint(parts[3], 10, 16); err != nil || t < 1 {
			return 1, fmt.Errorf("Invalid size specification: %s with error: %w", opts.UseWindowSize, err)
		}

View on GitHub (pinned to 6d5d0c4406)

Solutions

  1. Supply all four fields: --use-window-size=COLS,ROWS,XPIXEL,YPIXEL e.g. 80,24,1920,1080
  2. Drop --use-window-size entirely and let icat query the terminal automatically
  3. Check script/alias definitions for a truncated value

Example fix

// before
kitten icat --use-window-size=1920,1080 img.png
// after
kitten icat --use-window-size=80,24,1920,1080 img.png
Defensive patterns

Strategy: validation

Validate before calling

re := regexp.MustCompile(`^[1-9][0-9]{0,4},[1-9][0-9]{0,4},[1-9][0-9]{0,4},[1-9][0-9]{0,4}$`)
if !re.MatchString(useWindowSize) { log.Fatal("need COLS,ROWS,XPIXEL,YPIXEL") }

Prevention

When it happens

Trigger: Passing --use-window-size with fewer or more than 4 comma-separated values, e.g. --use-window-size=80,24 or --use-window-size=80,24,1920,1080,extra.

Common situations: Scripts assuming only columns/rows are needed; copying a TIOCGWINSZ-style value of 2 fields; trailing comma producing empty parts.

Related errors


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