{"record":{"id":"72f149a30e0bb048","repo":"kovidgoyal/kitty","slug":"invalid-value-for-self-name-value-r","errorCode":null,"errorMessage":"Invalid value for {self._name}: {value!r}","messagePattern":"Invalid value for (.+?): (.+?)","errorType":"validation","errorClass":"KeyError","httpStatus":null,"severity":"error","filePath":"kitty/options/utils.py","lineNumber":1400,"sourceCode":"\nclass LiteralField(Generic[T]):\n    def __init__(self, vals: tuple[T, ...]):\n        self._vals = vals\n\n    def __set_name__(self, owner: object, name: str) -> None:\n        self._name = name\n\n    def __get__(self, obj: object, type: type | None = None) -> T:\n        if obj is None:\n            return self._vals[0]\n        val = obj.__dict__.get(self._name)\n        if val is None or isinstance(val, LiteralField):\n            return self._vals[0]\n        return cast(T, val)\n\n    def __set__(self, obj: object, value: str) -> None:\n        if value not in self._vals:\n            raise KeyError(f'Invalid value for {self._name}: {value!r}')\n        obj.__dict__[self._name] = value\n\n\nOnUnknown = Literal['beep', 'end', 'ignore', 'passthrough']\nOnAction = Literal['keep', 'end']\n\n\nclass KeyFallbackType(enum.Enum):\n    shifted = 'shifted'\n    alternate = 'alternate'\n\n    def __repr__(self) -> str:\n        return f'KeyFallbackType.{self.value}'\n\n\n@dataclass(frozen=True)\nclass KeyMapOptions:\n    when_focus_on: str = ''","sourceCodeStart":1382,"sourceCodeEnd":1418,"githubUrl":"https://github.com/kovidgoyal/kitty/blob/6d5d0c440603ad9bdf6dcd599f73f6dde21acb44/kitty/options/utils.py#L1382-L1418","documentation":"A LiteralField/enum-style option descriptor validates that the assigned string is one of its allowed literal values; anything else raises KeyError naming the option and offending value.","triggerScenarios":"Assigning a value outside the option's literal set, e.g. setting a 'beep|end|ignore|passthrough'-style option to 'warn', or case mismatches like 'Beep'.","commonSituations":"Misspelled or case-sensitive enum values in kitty.conf, values valid only in other kitty versions, or programmatic assignment bypassing normalization.","solutions":["Use one of the exact allowed values listed for the option","Match case exactly (values are case-sensitive)","Consult the option's docs for the accepted literals"],"exampleFix":"# before\nnotify_on_cmd_beep Warn\n# after\nnotify_on_cmd_beep ignore","handlingStrategy":"type-guard","validationCode":"def valid_literal(field_vals: tuple[str, ...], v: str) -> bool:\n    return v in field_vals","typeGuard":"def is_valid_literal(v: str, allowed: tuple[str, ...]) -> bool:\n    return v in allowed","tryCatchPattern":null,"preventionTips":["Match enum values exactly including case"],"tags":["kitty","config","enum","descriptor"],"backgroundTag":"enum-value-invalid","analyzedSha":"6d5d0c440603ad9bdf6dcd599f73f6dde21acb44","analyzedAt":"2026-08-27T14:20:20.142Z","schemaVersion":2},"datasetVersion":"2026-08-27T19:17:21.184Z"}