Skip to content

[BUG] KeyError: 'tvdb_id' when processing Emby webhook if tvdb_id is missing from TMDB response #701

@bison529

Description

@bison529

Describe the bug

When processing a webhook from Emby for shows like The Walking Dead (e.g., S02E03 or S02E04), the application crashes with a KeyError: 'tvdb_id'.

It appears that the method app.providers.tmdb.tv_with_seasons(...) does not always return a tvdb_id, but the code assumes its presence unconditionally.


Full traceback:

KeyError: 'tvdb_id'
File "/yamtrack/integrations/webhooks/base.py", line 65, in _process_tv
  tvdb_id = app.providers.tmdb.tv_with_seasons(media_id, [season_number])["tvdb_id"]

Steps to reproduce

  1. Connect Emby with the webhook endpoint /webhook/emby/...
  2. Play an episode from a TV series that does not include tvdb_id in the TMDB response
  3. The webhook triggers a 500 Internal Server Error
  4. The log shows a KeyError related to the missing tvdb_id

Expected behavior

The code should handle the case when tvdb_id is missing gracefully, avoiding a hard crash.

Environment

  • Django: 5.2.2
  • Python: 3.12
  • Container: Custom Docker image (built from project Dockerfile)
  • DB: PostgreSQL 15

Thanks for the great work on Yamtrack 🙌 — this issue just needs a bit of defensive coding to improve webhook stability.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingfixed in devFixed in the development branch

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions