Commit 80cf187
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 80cf187
3 files changed
+14
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
14 | 19 | | |
15 | 20 | | |
16 | 21 | | |
| |||
33 | 38 | | |
34 | 39 | | |
35 | 40 | | |
36 | | - | |
| 41 | + | |
37 | 42 | | |
38 | 43 | | |
39 | 44 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
| 7 | + | |
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
116 | 116 | | |
117 | 117 | | |
118 | 118 | | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
119 | 123 | | |
120 | 124 | | |
121 | 125 | | |
| 126 | + | |
| 127 | + | |
122 | 128 | | |
123 | 129 | | |
124 | 130 | | |
| |||
0 commit comments