From 4c22ababc40467f5190792dddec3dde7cc4bfe3a Mon Sep 17 00:00:00 2001 From: Marius Stedjan <4471935+willmakenoise@users.noreply.github.com> Date: Fri, 13 Nov 2026 18:59:14 +0100 Subject: [PATCH] Fix Seerr request media action crashing when nothing is left to request (#192284) --- homeassistant/components/overseerr/manifest.json | 2 +- homeassistant/components/overseerr/services.py | 8 +++++++- homeassistant/components/overseerr/strings.json | 3 +++ requirements_all.txt | 2 +- tests/components/overseerr/test_services.py | 13 +++++++++++++ 5 files changed, 25 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/overseerr/manifest.json b/homeassistant/components/overseerr/manifest.json index e853333bc0c9..d43ba960915b 100644 --- a/homeassistant/components/overseerr/manifest.json +++ b/homeassistant/components/overseerr/manifest.json @@ -11,5 +11,5 @@ "integration_type": "service", "iot_class": "local_push", "quality_scale": "platinum", - "requirements": ["python-overseerr==0.10.0"] + "requirements": ["python-overseerr==0.10.1"] } diff --git a/homeassistant/components/overseerr/services.py b/homeassistant/components/overseerr/services.py index 71316975043b..748ac9ac01e4 100644 --- a/homeassistant/components/overseerr/services.py +++ b/homeassistant/components/overseerr/services.py @@ -7,6 +7,7 @@ from typing import Any, Literal, cast import probatio from python_overseerr import OverseerrClient, OverseerrConnectionError +from python_overseerr.exceptions import OverseerrNothingToRequestError from homeassistant.const import CommonServiceArgument from homeassistant.core import ( @@ -16,7 +17,7 @@ from homeassistant.core import ( SupportsResponse, callback, ) -from homeassistant.exceptions import HomeAssistantError +from homeassistant.exceptions import HomeAssistantError, ServiceValidationError from homeassistant.helpers import service from homeassistant.util.json import JsonValueType @@ -185,6 +186,11 @@ async def _async_request_media(call: ServiceCall) -> ServiceResponse: try: # We can always pass in the seasons, they will be ignored if the media type isn't TV request = await client.create_request(media_type, media_id, seasons) + except OverseerrNothingToRequestError as err: + raise ServiceValidationError( + translation_domain=DOMAIN, + translation_key="nothing_to_request", + ) from err except OverseerrConnectionError as err: raise HomeAssistantError( translation_domain=DOMAIN, diff --git a/homeassistant/components/overseerr/strings.json b/homeassistant/components/overseerr/strings.json index 64c144c96b1a..b05dcda156be 100644 --- a/homeassistant/components/overseerr/strings.json +++ b/homeassistant/components/overseerr/strings.json @@ -113,6 +113,9 @@ }, "connection_error": { "message": "Error connecting to the Seerr instance: {error}" + }, + "nothing_to_request": { + "message": "There is nothing left to request, the media has already been requested or is already available." } }, "selector": { diff --git a/requirements_all.txt b/requirements_all.txt index ec72757e0a6a..bfea910102c0 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -2858,7 +2858,7 @@ python-opensky==1.0.1 python-otbr-api==3.1.0 # homeassistant.components.overseerr -python-overseerr==0.10.0 +python-overseerr==0.10.1 # homeassistant.components.picnic python-picnic-api2==2.0.1 diff --git a/tests/components/overseerr/test_services.py b/tests/components/overseerr/test_services.py index bf151c193a2b..420277a6f06c 100644 --- a/tests/components/overseerr/test_services.py +++ b/tests/components/overseerr/test_services.py @@ -6,6 +6,7 @@ from unittest.mock import AsyncMock import pytest from pytest_homeassistant.common import MockConfigEntry from python_overseerr import OverseerrConnectionError +from python_overseerr.exceptions import OverseerrNothingToRequestError from python_overseerr.models import MediaType from syrupy.assertion import SnapshotAssertion @@ -165,6 +166,18 @@ async def test_service_request_media( HomeAssistantError, "Error connecting to the Seerr instance: Timeout", ), + ( + OverseerrService.REQUEST_MEDIA, + { + OverseerrServiceArgument.MEDIA_TYPE: "tv", + OverseerrServiceArgument.MEDIA_ID: "123456789", + OverseerrServiceArgument.SEASONS: "all", + }, + "create_request", + OverseerrNothingToRequestError("No seasons available to request"), + ServiceValidationError, + "There is nothing left to request", + ), ], ) async def test_services_connection_error(