tmuxp icon indicating copy to clipboard operation
tmuxp copied to clipboard

Fail gracefully on invalid YAML configuration

Open lordievader opened this issue 5 years ago • 1 comments

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:

  1. 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.

lordievader avatar Aug 14 '19 09:08 lordievader

There could be a more user-friendly warning as well.

tony avatar Mar 19 '22 18:03 tony