Uploaded image for project: 'ListenBrainz'
  1. ListenBrainz
  2. LB-743

Some exception handling swallows traceback

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Normal
    • Resolution: Fixed
    • Fix Version/s: None
    • Component/s: troi
    • Labels:
      None

      Description

      In some pipelines we catch exceptions and wrap them in RuntimeError: https://github.com/metabrainz/troi-recommendation-playground/blob/2628ae8436eb85fde73565d0e179942d592be384/troi/musicbrainz/recording_lookup.py#L43-L48

      Later, in the Playlist command we catch this error and output it so that the process doesn't quit: https://github.com/metabrainz/troi-recommendation-playground/blob/645966f6940853f3802bcf6ffe4f13d1f7728a19/troi.py#L54-L56

      However, this means that exceptions are lacking a traceback, which makes it difficult to work out where the error is coming from:

      Failed to generate playlist: 'Response' object has no attribute 'tet'

      There are still some places where we don't catch exceptions and they filter up and exit the playlister:

      Traceback (most recent call last):
        File "troi.py", line 99, in <module>
          cli()
        File "/Users/alastair/code/metabrainz/troi-recommendation-playground/env/lib/python3.8/site-packages/click/core.py", line 829, in __call__
          return self.main(*args, **kwargs)
        File "/Users/alastair/code/metabrainz/troi-recommendation-playground/env/lib/python3.8/site-packages/click/core.py", line 782, in main
          rv = self.invoke(ctx)
        File "/Users/alastair/code/metabrainz/troi-recommendation-playground/env/lib/python3.8/site-packages/click/core.py", line 1259, in invoke
          return _process_result(sub_ctx.command.invoke(sub_ctx))
        File "/Users/alastair/code/metabrainz/troi-recommendation-playground/env/lib/python3.8/site-packages/click/core.py", line 1066, in invoke
          return ctx.invoke(self.callback, **ctx.params)
        File "/Users/alastair/code/metabrainz/troi-recommendation-playground/env/lib/python3.8/site-packages/click/core.py", line 610, in invoke
          return callback(*args, **kwargs)
        File "troi.py", line 53, in playlist
          playlist.generate(debug)
        File "/Users/alastair/code/metabrainz/troi-recommendation-playground/troi/__init__.py", line 48, in generate
          recordings = self.read(source_lists, debug)
        File "/Users/alastair/code/metabrainz/troi-recommendation-playground/troi/playlist.py", line 37, in read
          'artist_name' : e.artist.name ,
      AttributeError: 'NoneType' object has no attribute 'name'
      

      We should determine where it makes sense to swallow exceptions and continue, however in this case we should still provide some ability to print the full traceback for debugging

        Attachments

          Activity

            People

            Assignee:
            rob Robert Kaye
            Reporter:
            alastairp Alastair Porter
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Packages

                Version Package