kovidgoyal/kitty · error
%s is not a valid contrast value
Error message
%s is not a valid contrast value
What it means
The `set-contrast` command only accepts the literal strings `normal` (mapped to uint32 0) and `high` (mapped to uint32 1). Any other string falls into the default branch and is rejected.
Source
Thrown at kittens/desktop_ui/main.go:134
})
parent.AddSubCommand(&cli.Command{
Name: "set-contrast",
ShortDescription: "Change the contrast. Can be high or normal.",
Usage: " high|normal",
Run: func(cmd *cli.Command, args []string) (rc int, err error) {
if len(args) != 1 {
cmd.ShowHelp()
return 1, fmt.Errorf("must specify the new contrast value")
}
var v dbus.Variant
switch args[0] {
case "normal":
v = dbus.MakeVariant(uint32(0))
case "high":
v = dbus.MakeVariant(uint32(1))
default:
return 1, fmt.Errorf("%s is not a valid contrast value", args[0])
}
err = set_variant_setting(PORTAL_APPEARANCE_NAMESPACE, PORTAL_CONTRAST_KEY, v, false)
return utils.IfElse(err == nil, 0, 1), err
},
})
st := parent.AddSubCommand(&cli.Command{
Name: "set-setting",
ShortDescription: "Change an arbitrary setting",
Usage: " key [value]",
HelpText: "Set an arbitrary setting. If you want to set the color-scheme use the dedicated command for it. Use this command with care as it does no validation for the type of value. The syntax for specifying values is described at: :link:`the glib docs <https://docs.gtk.org/glib/gvariant-text-format.html>`. Leaving out the value or specifying an empty value, will delete the setting.",
Run: func(cmd *cli.Command, args []string) (rc int, err error) {
val := ""
if len(args) < 1 {
cmd.ShowHelp()
return 1, fmt.Errorf("must specify the key")
}
if len(args) > 1 {
val = args[1]View on GitHub (pinned to 6d5d0c4406)
Solutions
- Use exactly `normal` or `high` as the contrast value
- If forwarding from a script, map your internal values to these two strings first
Example fix
# before kitten desktop-ui set-contrast 1 # after kitten desktop-ui set-contrast high
Defensive patterns
Strategy: validation
Validate before calling
valid := map[string]bool{"normal": true, "high": true}
if !valid[args[0]] { /* reject before calling */ } Type guard
func isContrastValue(s string) bool { return s == "normal" || s == "high" } Prevention
- Whitelist the two literal values in calling code
- Map external vocabularies to normal/high before invoking
When it happens
Trigger: Passing anything other than `normal` or `high`, e.g. `set-contrast low`, `set-contrast 1`, `set-contrast TRUE`.
Common situations: Users guessing numeric or boolean values; scripts forwarding values from other tools that use different vocabularies.
Related errors
- must specify the new contrast value
- must specify the key
- no arguments allowed
- No kitten named {original_kitten_name}
- This should be run as kitten ssh
AI-assisted analysis of kovidgoyal/kitty@6d5d0c4406 (2026-08-27).
Data as JSON: /api/errors/93553590a2ff8f96.
Report an issue: GitHub.