fix: prevent IndexError when window config has empty panes list#1
Open
miloquinn wants to merge 2 commits into
Open
fix: prevent IndexError when window config has empty panes list#1miloquinn wants to merge 2 commits into
miloquinn wants to merge 2 commits into
Conversation
…cmds why: YAML parses PORT: 1999 as int, but tmux set-environment expects strings, causing TypeError. Similarly, YAML comments in shell_command lists become None entries, causing TypeError when expand_cmd tries to access None["cmd"]. what: - Add _stringify_environment() helper to builder.py - Apply str() coercion at session, window, and pane environment levels - Filter None entries from shell_command lists in expand_cmd() - Fixes tmux-python#503 (env var types) and tmux-python#391 (None in shell_command_before)
Line 661 accesses panes[0].get('environment', ...) without checking if
panes is empty. When a window config has an empty panes list, this
crashes with IndexError.
Fix: add 'if panes' guard to match the pattern used on line 649 and
lines 655-658, which both properly guard against empty panes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Line 661 accesses panes[0].get('environment', ...) without checking if the panes list is empty. When a window configuration contains an empty panes list, this crashes with IndexError.
Root Cause
In src/tmuxp/workspace/builder.py line 661, the code accesses panes[0].get(...) without an empty-list guard. Lines 649-650 and 655-658 both properly guard with if panes, but line 661 was missing this check.
Fix
Add if panes guard: environment = panes[0].get(environment, window_config.get(environment)) if panes else window_config.get(environment)
Impact