tmux-python / tmux-python/tmuxp
Fail gracefully on invalid YAML configuration
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 4.6k
- Forks
- 248
- Avg merge
- 2h 13m
- Merged PRs (30d)
- 1
Description
Step 1: Provide a summary of your problem
Tmuxp does not fail gracefully on trying to load an invalid yaml configuration. You get a stack-trace which is not very helpful.
Step 2: Provide tmuxp details
- Python version: Python 3.6.5
- system PATH:
/home/lordievader/.rvm/gems/ruby-2.3.1/bin:/home/lordievader/.rvm/gems/ruby-2.3.1@global/bin:/home/lordievader/.rvm/rubies/ruby-2.3.1/bin:/usr/lib/llvm/7/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/bin:/home/lordievader/.rvm/bin - tmux version: tmux 2.7
- tmuxp version: tmuxp 1.5.1
- libtmux version: 0.8.1
- shell: zsh
- output of
tmuxp freeze <SESSION_NAME>: "Session not found"
Step 3: Describe your environment
- Architecture: AMD64
- OS version: Gentoo
Step 4: Describe the problem:
Steps to reproduce:
- Create a config like:
session_name: tutorial-paper
windows:
- window_name: dev window
layout: tiled
shell_command_before:
- cd ~/phd/surveys_and_tutorials
panes:
-echo first pane
Notice the lack of a space in the first pane command.
2. Try to load the session.
3. Get a lovely stack trace.
Observed Results:
When loading this configuration you get this stack trace:
Traceback (most recent call last):
File "/usr/lib/python-exec/python3.6/tmuxp", line 11, in <module>
load_entry_point('tmuxp==1.5.1', 'console_scripts', 'tmuxp')()
File "/usr/lib64/python3.6/site-packages/click/core.py", line 764, in __call__
return self.main(*args, **kwargs)
File "/usr/lib64/python3.6/site-packages/click/core.py", line 717, in main
rv = self.invoke(ctx)
File "/usr/lib64/python3.6/site-packages/click/core.py", line 1137, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/lib64/python3.6/site-packages/click/core.py", line 956, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/lib64/python3.6/site-packages/click/core.py", line 555, in invoke
return callback(*args, **kwargs)
File "/usr/lib64/python3.6/site-packages/click/decorators.py", line 17, in new_func
return f(get_current_context(), *args, **kwargs)
File "/usr/lib64/python3.6/site-packages/tmuxp/cli.py", line 812, in command_load
load_workspace(config[-1], **tmux_options)
File "/usr/lib64/python3.6/site-packages/tmuxp/cli.py", line 496, in load_workspace
sconfig = config.expand(sconfig, os.path.dirname(config_file))
File "/usr/lib64/python3.6/site-packages/tmuxp/config.py", line 283, in expand
sconf['windows'] = [expand(window, parent=sconf) for window in sconf['windows']]
File "/usr/lib64/python3.6/site-packages/tmuxp/config.py", line 283, in <listcomp>
sconf['windows'] = [expand(window, parent=sconf) for window in sconf['windows']]
File "/usr/lib64/python3.6/site-packages/tmuxp/config.py", line 289, in expand
pconf = sconf['panes'][p_index] = {}
TypeError: 'str' object does not support item assignment
Expected Results:
I expected the error to contain something about having an invalid YAML configuration.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at tmuxp/cli.py in command_load and load_workspace, then follow configuration expansion into tmuxp/config.py at expand. Reproduce the example with the malformed panes entry and determine how invalid YAML configuration is currently surfaced. Done means loading it reports a helpful configuration error instead of the shown stack trace.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100