Skip to content

fix: prevent IndexError when window config has empty panes list#1

Open
miloquinn wants to merge 2 commits into
masterfrom
fix/empty-panes-environment-crash
Open

fix: prevent IndexError when window config has empty panes list#1
miloquinn wants to merge 2 commits into
masterfrom
fix/empty-panes-environment-crash

Conversation

@miloquinn

@miloquinn miloquinn commented May 22, 2026

Copy link
Copy Markdown
Owner

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

  • Severity: Medium (crashes on empty panes config)
  • Triggered by: user config with panes: []
  • Backward compatible

miloquinn and others added 2 commits May 16, 2026 16:58
…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.
@miloquinn miloquinn changed the title fix: empty panes fix: prevent IndexError when window config has empty panes list May 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant