{"record":{"id":"7dca0b855d657128","repo":"kovidgoyal/kitty","slug":"val-is-not-a-valid-layout","errorCode":null,"errorMessage":"{val} is not a valid layout","messagePattern":"(.+?) is not a valid layout","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"kitty/session.py","lineNumber":114,"sourceCode":"\n    @property\n    def has_non_background_processes(self) -> bool:\n        for t in self.tabs:\n            if t.has_non_background_processes:\n                return True\n        return False\n\n    def add_tab(self, opts: Options, name: str = '') -> None:\n        if self.tabs and not self.tabs[-1].windows:\n            del self.tabs[-1]\n        self.tabs.append(Tab(opts, name))\n\n    def set_next_title(self, title: str) -> None:\n        self.tabs[-1].next_title = title.strip()\n\n    def set_layout(self, val: str) -> None:\n        if val.partition(':')[0] not in all_layouts:\n            raise ValueError(f'{val} is not a valid layout')\n        self.tabs[-1].layout = val\n\n    def set_layout_state(self, val: str) -> None:\n        self.tabs[-1].layout_state = json.loads(val)\n\n    def add_window(self, cmd: None | str | list[str], expand: Callable[[str], str] = lambda x: x) -> None:\n        from .launch import parse_launch_args\n\n        needs_expandvars = False\n        if isinstance(cmd, str):\n            needs_expandvars = True\n            cmd = list(shlex_split(cmd)) if cmd else []\n        serialize_data: dict[str, Any] = {'id': 0, 'cmd_at_shell_startup': ()}\n        if cmd and cmd[0].startswith(unserialize_launch_flag):\n            serialize_data = json.loads(cmd[0][len(unserialize_launch_flag) :])\n            del cmd[0]\n        spec = parse_launch_args(cmd)\n        if needs_expandvars:","sourceCodeStart":96,"sourceCodeEnd":132,"githubUrl":"https://github.com/kovidgoyal/kitty/blob/6d5d0c440603ad9bdf6dcd599f73f6dde21acb44/kitty/session.py#L96-L132","documentation":"Raised by Session.set_layout when the layout name (the part before the first ':') in a session file's layout directive is not one of kitty's known layouts. The full layout string may include a state suffix after ':', but the prefix must match an entry in all_layouts.","triggerScenarios":"A session file line like 'layout grid' when the layout name is misspelled or not compiled in (e.g. 'splits' without the splits dependency, 'fat3' custom layout not registered), or a custom layout not enabled in enabled_layouts.","commonSituations":"Session files written for a newer/older kitty version or another machine where a layout (e.g. 'splits') isn't available; typos like 'gird' or 'tall:' with wrong casing.","solutions":["Check the exact layout name against kitty's all_layouts (run `kitty --debug-layouts` or check docs): valid names include stack, tall, fat, grid, horizontal, vertical, splits","Fix the typo in the session file's layout line","If using a custom layout, ensure it's registered/enabled before loading the session","Note the part before ':' is what's validated: 'grid:...' must still start with a valid name"],"exampleFix":"# before (session file)\nlayout gird\n# after\nlayout grid","handlingStrategy":"validation","validationCode":"from kitty.layout.base import all_layouts\n\ndef valid_layout(v: str) -> bool:\n    return v.partition(':')[0] in all_layouts","typeGuard":null,"tryCatchPattern":"try:\n    create_sessions(session_data)\nexcept ValueError as e:\n    if 'is not a valid layout' in str(e):\n        # report and fall back to default layout\n        ...","preventionTips":["Validate layout names against all_layouts before writing session files","Pin session files to layouts available in your kitty version","Test session files after kitty upgrades"],"tags":["kitty","session","layout","config-validation"],"backgroundTag":"invalid-config-value","analyzedSha":"6d5d0c440603ad9bdf6dcd599f73f6dde21acb44","analyzedAt":"2026-08-27T14:20:20.142Z","schemaVersion":2},"datasetVersion":"2026-08-27T19:17:21.184Z"}