{"record":{"id":"8a24d5c13a697e6e","repo":"kovidgoyal/kitty","slug":"failed-to-load-custom-tab-bar-py-module-with-error","errorCode":null,"errorMessage":"Failed to load custom tab_bar.py module with error: {e}","messagePattern":"Failed to load custom tab_bar\\.py module with error: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kitty/tab_bar.py","lineNumber":661,"sourceCode":"\n    end = screen.cursor.x\n    if end < screen.columns:\n        screen.draw(' ')\n    return end\n\n\n@run_once\ndef load_custom_draw_tab_module() -> dict[str, Any]:\n    import runpy\n    import traceback\n\n    try:\n        return runpy.run_path(os.path.join(config_dir, 'tab_bar.py'))\n    except FileNotFoundError:\n        return {}\n    except Exception as e:\n        traceback.print_exc()\n        log_error(f'Failed to load custom tab_bar.py module with error: {e}')\n        return {}\n\n\n@run_once\ndef load_custom_draw_tab() -> DrawTabFunc:\n    m = load_custom_draw_tab_module()\n    func: DrawTabFunc | None = m.get('draw_tab')\n    if func is None:\n        return draw_tab_with_fade\n\n    @wraps(func)\n    def draw_tab(\n        draw_data: DrawData, screen: Screen, tab: TabBarData, before: int, max_tab_length: int, index: int, is_last: bool, extra_data: ExtraData\n    ) -> int:\n        try:\n            return func(draw_data, screen, tab, before, max_tab_length, index, is_last, extra_data)\n        except Exception as e:\n            log_error(f'Custom draw tab function failed with error: {e}')","sourceCodeStart":643,"sourceCodeEnd":679,"githubUrl":"https://github.com/kovidgoyal/kitty/blob/6d5d0c440603ad9bdf6dcd599f73f6dde21acb44/kitty/tab_bar.py#L643-L679","documentation":"kitty found a user tab_bar.py in the config dir but importing/executing it raised an exception (other than FileNotFoundError). The custom tab bar is disabled and the default is used.","triggerScenarios":"runpy.run_path(config_dir/tab_bar.py) raises — syntax error, NameError at import time, or incompatible imports — in load_custom_draw_tab_module.","commonSituations":"tab_bar.py written for an older kitty API (draw_tab signature changes), Python typos, or missing helper imports after refactor.","solutions":["Check the traceback kitty printed for the failing line in tab_bar.py","Match your draw_tab signature to the current kitty docs: (draw_data, screen, tab, before, max_tab_length, index, is_last, extra_data)","Test locally: python3 -c \"import runpy; runpy.run_path('~/.config/kitty/tab_bar.py', run_name='x')\""],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"import runpy\ntry:\n    runpy.run_path(os.path.expanduser('~/.config/kitty/tab_bar.py'), run_name='tab_bar')\nexcept Exception as e:\n    print('tab_bar.py broken:', e)","typeGuard":null,"tryCatchPattern":"try:\n    module = runpy.run_path(tab_bar_path)\nexcept FileNotFoundError:\n    module = {}  # no customization, fine\nexcept Exception:\n    module = {}  # broken; fall back to default tab bar","preventionTips":["Re-test tab_bar.py after every kitty upgrade (draw_tab signature has changed before)","Keep customizations minimal and version-pinned with kitty releases"],"tags":["kitty","tab-bar","customization","plugin-load"],"backgroundTag":"user-plugin-load-failed","analyzedSha":"6d5d0c440603ad9bdf6dcd599f73f6dde21acb44","analyzedAt":"2026-08-27T14:20:20.142Z","schemaVersion":2},"datasetVersion":"2026-08-27T19:17:21.184Z"}