#1051077 reportbug fails to execute if there is an invalid file in sources.list.d

#1051077#5
Date:
2023-09-02 11:28:09 UTC
From:
To:
Dear Maintainer,

   * What led up to the situation?
     Tried to add a deb822 format .sources file to my system, then launch reportbug

   * What was the outcome of this action?
     Reportbug crashed with

Traceback (most recent call last):
  File "/usr/bin/reportbug", line 40, in <module>
    from reportbug import utils
  File "/usr/lib/python3/dist-packages/reportbug/utils.py", line 100, in <module>
    _apt_cache = apt.Cache()
                 ^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/apt/cache.py", line 170, in __init__
    self.open(progress)
  File "/usr/lib/python3/dist-packages/apt/cache.py", line 232, in open
    self._cache = apt_pkg.Cache(progress)
                  ^^^^^^^^^^^^^^^^^^^^^^^
apt_pkg.Error: E:Unable to parse package file /etc/apt/sources.list.d/grafana.sources (1), E:The list of sources could not be read.


   * What outcome did you expect instead?
     reportbug to still work and perhaps warn about the invalid file.
     IMO reportbug needs to be hardened against these kind of situations

*** End of the template - remove these template lines ***