kovidgoyal/kitty · error

Invalid size specification: %s with error: %w

Error message

Invalid size specification: %s with error: %w

What it means

Parsing the first field (terminal columns) of --use-window-size as a base-10 uint16 failed or was zero. icat requires each of the four numbers to parse cleanly and be >= 1.

Source

Thrown at kittens/icat/main.go:200

		} 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)
		}
		screen_size.Ypixel = uint16(t)
		if screen_size.Xpixel < screen_size.Col {
			return 1, fmt.Errorf("Invalid size specification: %s with error: The pixel width is smaller than the number of columns", opts.UseWindowSize)
		}
		if screen_size.Ypixel < screen_size.Row {

View on GitHub (pinned to 6d5d0c4406)

Solutions

  1. Use a positive integer <= 65535 for the columns field
  2. Ensure it is a column count (e.g. 80), not pixels
  3. Validate the string with a regex like ^[1-9][0-9]{0,4}$ before invoking

Example fix

// before
--use-window-size=0,24,1920,1080
// after
--use-window-size=80,24,1920,1080
Defensive patterns

Strategy: validation

Validate before calling

parts := strings.Split(spec, ",")
if n, err := strconv.ParseUint(parts[0], 10, 16); err != nil || n < 1 { log.Fatal("bad columns") }

Prevention

When it happens

Trigger: --use-window-size where parts[0] is non-numeric (e.g. 'abc'), negative, > 65535, or 0, e.g. --use-window-size=0,24,1920,1080.

Common situations: Placeholder/uninitialized 0 values in scripts; passing fractional sizes; passing pixel values in the columns slot; note err may be nil when the value parsed but was < 1.

Related errors


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