{"record":{"id":"eab4054edb406464","repo":"kovidgoyal/kitty","slug":"invalid-tab-title-template-template-with-erro","errorCode":null,"errorMessage":"Invalid tab title template: \"{template}\" with error: {e}","messagePattern":"Invalid tab title template: \"(.+?)\" with error: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"kitty/tab_bar.py","lineNumber":138,"sourceCode":"    LEFT_EDGE: 'left',\n    TOP_EDGE: 'top',\n    RIGHT_EDGE: 'right',\n    BOTTOM_EDGE: 'bottom',\n}\n\n\ndef normalized_tab_bar_align(align: str) -> Literal['start', 'end', 'center']:\n    match align:\n        case 'left' | 'start':\n            return 'start'\n        case 'right' | 'end':\n            return 'end'\n    return 'center'\n\n\n@lru_cache\ndef report_template_failure(template: str, e: str) -> None:\n    log_error(f'Invalid tab title template: \"{template}\" with error: {e}')\n\n\n@lru_cache\ndef compile_template(template: str) -> Any:\n    try:\n        return compile('f\"\"\"' + template + '\"\"\"', '<template>', 'eval')\n    except Exception as e:\n        report_template_failure(template, str(e))\n\n\nclass ColorFormatter:\n    draw_data: DrawData\n    tab_data: TabBarData\n\n    def __init__(self, which: str):\n        self.which = which\n\n    def __getattr__(self, name: str) -> str:","sourceCodeStart":120,"sourceCodeEnd":156,"githubUrl":"https://github.com/kovidgoyal/kitty/blob/6d5d0c440603ad9bdf6dcd599f73f6dde21acb44/kitty/tab_bar.py#L120-L156","documentation":"A tab title template (tab_title_template / active_tab_title_template) failed to compile as a Python f-string expression. kitty logs the invalid template once (lru_cache dedupes) and falls back to a plain title.","triggerScenarios":"compile('f\"\"\"'+template+'\"\"\"') raises SyntaxError, reported via report_template_failure from compile_template/apply_title_template.","commonSituations":"Templates using unsupported syntax: {index+} style placeholders with typos, unmatched braces, or trying to call functions not in the template namespace (fmt, index, layout_name...).","solutions":["Validate the template as an f-string expression: python3 -c 'compile(f\"\"\"<template>\"\"\", \"<t>\", \"eval\")'","Use only documented variables (fmt, index, layout_name, num_windows, title) and fmt.date()","Fix unmatched braces — literal braces must be doubled {{ }}"],"exampleFix":"# before\ntab_title_template \"{index+1}: {title\"\n\n# after\ntab_title_template \"{index+1}: {title}\"","handlingStrategy":"validation","validationCode":"def template_ok(t: str) -> bool:\n    try:\n        compile('f\"\"\"' + t + '\"\"\"', '<template>', 'eval')\n        return True\n    except SyntaxError:\n        return False\n# validate before setting\ntemplate_ok('{index+1}: {title}') or fail()","typeGuard":"def is_valid_template(t: str) -> bool:\n    try:\n        compile('f\"\"\"' + t + '\"\"\"', '<t>', 'eval')\n        return True\n    except SyntaxError:\n        return False","tryCatchPattern":null,"preventionTips":["Escape literal braces as {{ and }}","Only use documented template variables: fmt, index, layout_name, num_windows, title"],"tags":["kitty","tab-bar","template","config"],"backgroundTag":"template-syntax-error","analyzedSha":"6d5d0c440603ad9bdf6dcd599f73f6dde21acb44","analyzedAt":"2026-08-27T14:20:20.142Z","schemaVersion":2},"datasetVersion":"2026-08-27T19:17:21.184Z"}