kovidgoyal/kitty · error

%s is not a valid test number

Error message

%s is not a valid test number

What it means

The wcswidth kitten accepts optional test numbers on its command line; one of the arguments could not be parsed as an integer. The kitten rejects the whole invocation before running anything.

Source

Thrown at tools/cli/wcswidth_kitten.go:262

		return 1, err
	}
	return
}

func WcswidthKittenEntryPoint(root *Command) {
	root.AddSubCommand(&Command{
		Name:            "__width_test__",
		Usage:           "[test number to run...]",
		HelpText:        "Test the terminal for compliance with the kitty text-sizing specification's splitting of text into cells. You can optionally specify specific test numbers to run.",
		Hidden:          true,
		OnlyArgsAllowed: true,
		Run: func(cmd *Command, args []string) (rc int, err error) {
			allowed_tests := utils.NewSet[int]()
			for _, arg := range args {
				if x, err := strconv.Atoi(arg); err == nil {
					allowed_tests.Add(x)
				} else {
					return 1, fmt.Errorf("%s is not a valid test number", arg)
				}
			}
			return main(allowed_tests)
		},
	})
}

View on GitHub (pinned to 6d5d0c4406)

Solutions

  1. Pass only space-separated integer test numbers, e.g. 'kitty +kitten wcswidth 3 7 12'
  2. Do not use ranges or commas; expand them yourself
  3. Run with no arguments to execute all tests

Example fix

// before
kitty +kitten wcswidth 1-5
// after
kitty +kitten wcswidth 1 2 3 4 5
Defensive patterns

Strategy: validation

Validate before calling

for _, a := range args {
    if _, err := strconv.Atoi(a); err != nil {
        return fmt.Errorf("%s is not a valid test number", a)
    }
}

Type guard

func isTestNumber(s string) bool { _, err := strconv.Atoi(s); return err == nil }

Prevention

When it happens

Trigger: Passing a non-numeric argument, e.g. 'kitty +kitten wcswidth foo' or '1-5' or '1,2' — only bare integers like '3' are accepted.

Common situations: Users trying to pass ranges or comma-separated lists of tests, or misspelling/adding flags the kitten does not support.

Related errors


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