Commit 50ff230
committed
Fail gracefully if config lacks the mandatory main section
Currently, if a user didn't put `[general]` section in config file,
bugwarrior fails like this:
Traceback (most recent call last):
File "/usr/bin/bugwarrior", line 8, in <module>
sys.exit(cli())
~~~^^
File "/usr/lib/python3.14/site-packages/click/core.py", line 1485, in __call__
return self.main(*args, **kwargs)
~~~~~~~~~^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.14/site-packages/click/core.py", line 1406, in main
rv = self.invoke(ctx)
File "/usr/lib/python3.14/site-packages/click/core.py", line 1873, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
File "/usr/lib/python3.14/site-packages/click/core.py", line 1269, in invoke
return ctx.invoke(self.callback, **ctx.params)
~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.14/site-packages/click/core.py", line 824, in invoke
return callback(*args, **kwargs)
File "/usr/lib/python3.14/site-packages/click/decorators.py", line 34, in new_func
return f(get_current_context(), *args, **kwargs)
File "/usr/lib/python3.14/site-packages/bugwarrior/command.py", line 62, in wrapped_subcommand_callback
return ctx.invoke(subcommand_callback, *args, **kwargs)
~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.14/site-packages/click/core.py", line 824, in invoke
return callback(*args, **kwargs)
File "/usr/lib/python3.14/site-packages/bugwarrior/command.py", line 105, in pull
config = _try_load_config(main_section, interactive, quiet)
File "/usr/lib/python3.14/site-packages/bugwarrior/command.py", line 35, in _try_load_config
return load_config(main_section, interactive, quiet)
File "/usr/lib/python3.14/site-packages/bugwarrior/config/load.py", line 122, in load_config
rawconfig['flavor'][main_section]['interactive'] = interactive
~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^
KeyError: 'general'
This is confusing — it looks more like bugwarrior broke due to some
API change in Python, rather than because of a user mistake.
So handle this case with explicit check. Now it will fail instead like
this:
CRITICAL:bugwarrior.command:Could not load configuration. Maybe you have not created a configuration file.
bugwarrior.config.load.ErrConfigLacksSection: Configuration lacks section "general"1 parent 5bca612 commit 50ff230
2 files changed
+6
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
| 13 | + | |
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
36 | | - | |
| 36 | + | |
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
115 | 115 | | |
116 | 116 | | |
117 | 117 | | |
| 118 | + | |
| 119 | + | |
118 | 120 | | |
119 | 121 | | |
120 | 122 | | |
121 | 123 | | |
| 124 | + | |
| 125 | + | |
122 | 126 | | |
123 | 127 | | |
124 | 128 | | |
| |||
0 commit comments