From de9646dba27b9fe55e18b65da18125a3c8e4b25a Mon Sep 17 00:00:00 2001 From: imSp4rky Date: Sun, 1 Nov 2026 20:06:09 -0700 Subject: [PATCH] fix(api): skip the local geoblock for a relayed tag not installed here --- tests/remote/unit/test_handler_proxy_policy.py | 5 +++++ unshackle/core/api/handlers.py | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/remote/unit/test_handler_proxy_policy.py b/tests/remote/unit/test_handler_proxy_policy.py index 264bebef..9b1f6c9d 100644 --- a/tests/remote/unit/test_handler_proxy_policy.py +++ b/tests/remote/unit/test_handler_proxy_policy.py @@ -63,6 +63,11 @@ def test_region_match_no_proxy(monkeypatch): assert handlers.resolve_handler_proxy({"client_region": "ca"}, "EXAMPLE", request("plainkey")) == (None, []) +def test_relayed_tag_not_installed_here_skips_the_local_geoblock(monkeypatch): + patch_server_region(monkeypatch, "CA") + assert handlers.resolve_handler_proxy({"client_region": "ca"}, "NOTHERE", request("plainkey")) == (None, []) + + def test_region_unknown_no_error(monkeypatch): patch_server_region(monkeypatch, None) assert handlers.resolve_handler_proxy({"client_region": "ca"}, "EXAMPLE", request("plainkey")) == (None, []) diff --git a/unshackle/core/api/handlers.py b/unshackle/core/api/handlers.py index 61885927..bd33b6a7 100644 --- a/unshackle/core/api/handlers.py +++ b/unshackle/core/api/handlers.py @@ -4686,7 +4686,9 @@ def resolve_handler_proxy( log.debug(f"Server region lookup failed: {e!r}") server_region = None - geoblock = getattr(Services.load(normalized_service), "GEOBLOCK", ()) or () + geoblock: Any = () + with suppress(KeyError): # a relayed tag need not be installed on this server + geoblock = getattr(Services.load(normalized_service), "GEOBLOCK", ()) or () if client_region.lower() in {x.lower() for x in geoblock}: raise APIError( APIErrorCode.GEOFENCE,