Commit a61bb2f
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:
Validation error found in /home/constantine/.config/bugwarrior/bugwarriorrc
See https://bugwarrior.readthedocs.io
No section: 'general'1 parent 715bec8 commit a61bb2f
2 files changed
+30
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
120 | 120 | | |
121 | 121 | | |
122 | 122 | | |
123 | | - | |
| 123 | + | |
| 124 | + | |
124 | 125 | | |
125 | 126 | | |
126 | 127 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
263 | 263 | | |
264 | 264 | | |
265 | 265 | | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
0 commit comments