{"record":{"id":"93553590a2ff8f96","repo":"kovidgoyal/kitty","slug":"s-is-not-a-valid-contrast-value","errorCode":null,"errorMessage":"%s is not a valid contrast value","messagePattern":"(.+?) is not a valid contrast value","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kittens/desktop_ui/main.go","lineNumber":134,"sourceCode":"\t})\n\tparent.AddSubCommand(&cli.Command{\n\t\tName:             \"set-contrast\",\n\t\tShortDescription: \"Change the contrast. Can be high or normal.\",\n\t\tUsage:            \" high|normal\",\n\t\tRun: func(cmd *cli.Command, args []string) (rc int, err error) {\n\t\t\tif len(args) != 1 {\n\t\t\t\tcmd.ShowHelp()\n\t\t\t\treturn 1, fmt.Errorf(\"must specify the new contrast value\")\n\t\t\t}\n\n\t\t\tvar v dbus.Variant\n\t\t\tswitch args[0] {\n\t\t\tcase \"normal\":\n\t\t\t\tv = dbus.MakeVariant(uint32(0))\n\t\t\tcase \"high\":\n\t\t\t\tv = dbus.MakeVariant(uint32(1))\n\t\t\tdefault:\n\t\t\t\treturn 1, fmt.Errorf(\"%s is not a valid contrast value\", args[0])\n\t\t\t}\n\t\t\terr = set_variant_setting(PORTAL_APPEARANCE_NAMESPACE, PORTAL_CONTRAST_KEY, v, false)\n\t\t\treturn utils.IfElse(err == nil, 0, 1), err\n\t\t},\n\t})\n\tst := parent.AddSubCommand(&cli.Command{\n\t\tName:             \"set-setting\",\n\t\tShortDescription: \"Change an arbitrary setting\",\n\t\tUsage:            \" key [value]\",\n\t\tHelpText:         \"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.\",\n\t\tRun: func(cmd *cli.Command, args []string) (rc int, err error) {\n\t\t\tval := \"\"\n\t\t\tif len(args) < 1 {\n\t\t\t\tcmd.ShowHelp()\n\t\t\t\treturn 1, fmt.Errorf(\"must specify the key\")\n\t\t\t}\n\t\t\tif len(args) > 1 {\n\t\t\t\tval = args[1]","sourceCodeStart":116,"sourceCodeEnd":152,"githubUrl":"https://github.com/kovidgoyal/kitty/blob/6d5d0c440603ad9bdf6dcd599f73f6dde21acb44/kittens/desktop_ui/main.go#L116-L152","documentation":"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.","triggerScenarios":"Passing anything other than `normal` or `high`, e.g. `set-contrast low`, `set-contrast 1`, `set-contrast TRUE`.","commonSituations":"Users guessing numeric or boolean values; scripts forwarding values from other tools that use different vocabularies.","solutions":["Use exactly `normal` or `high` as the contrast value","If forwarding from a script, map your internal values to these two strings first"],"exampleFix":"# before\nkitten desktop-ui set-contrast 1\n# after\nkitten desktop-ui set-contrast high","handlingStrategy":"validation","validationCode":"valid := map[string]bool{\"normal\": true, \"high\": true}\nif !valid[args[0]] { /* reject before calling */ }","typeGuard":"func isContrastValue(s string) bool { return s == \"normal\" || s == \"high\" }","tryCatchPattern":null,"preventionTips":["Whitelist the two literal values in calling code","Map external vocabularies to normal/high before invoking"],"tags":["cli","desktop-ui","kitty","invalid-value"],"backgroundTag":"cli-invalid-enum-value","analyzedSha":"6d5d0c440603ad9bdf6dcd599f73f6dde21acb44","analyzedAt":"2026-08-27T14:20:20.142Z","schemaVersion":2},"datasetVersion":"2026-08-27T19:17:21.184Z"}