From 693ab9f21744c1b13008a4c0bd5df48c78955ded Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 28 Feb 2026 09:54:09 +0000 Subject: [PATCH] Fix sonarr formatter crash when episodeFile.quality is a string Sonarr can send quality as a plain string instead of the nested {"quality": {"name": ...}} object. Guard with an isinstance check and fall back to using the string value directly. https://claude.ai/code/session_0188gygwJLdYhxbKvEz2jFjr --- app/formatters.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/app/formatters.py b/app/formatters.py index 3e5cd00..f0a5984 100644 --- a/app/formatters.py +++ b/app/formatters.py @@ -52,12 +52,11 @@ def format_sonarr(payload: dict) -> tuple[str, str]: episode = ep.get("episodeNumber", 0) ep_title = ep.get("title", "") - quality = ( - payload.get("episodeFile", {}) - .get("quality", {}) - .get("quality", {}) - .get("name", "Unknown") - ) + quality_field = payload.get("episodeFile", {}).get("quality", {}) + if isinstance(quality_field, dict): + quality = quality_field.get("quality", {}).get("name", "Unknown") + else: + quality = str(quality_field) if quality_field else "Unknown" header = f"\U0001f4fa **{series_title}** \u2014 S{season:02d}E{episode:02d}" if ep_title: