Fix request detail load failures
Magent CI/CD / verify (push) Failing after 11m3s
Magent CI/CD / deploy-prod (push) Has been skipped

This commit is contained in:
2026-06-18 21:10:56 +12:00
parent a8aa8e38e2
commit 8f03e315b8
3 changed files with 79 additions and 3 deletions
+1 -1
View File
@@ -118,6 +118,7 @@ def _cache_get(key: str) -> Optional[Dict[str, Any]]:
def _cache_set(key: str, payload: Dict[str, Any]) -> None:
_detail_cache[key] = (time.time() + CACHE_TTL_SECONDS, payload)
_failed_detail_cache.pop(key, None)
def _status_label_with_jellyfin(current_status: Any, jellyfin_available: bool) -> str:
@@ -169,7 +170,6 @@ async def _request_is_available_in_jellyfin(
return True
availability_cache[cache_key] = False
return False
_failed_detail_cache.pop(key, None)
def _failure_cache_has(key: str) -> bool:
+17
View File
@@ -11,6 +11,7 @@ from backend.app.config import settings
from backend.app.network_security import request_trusts_forwarded_headers, validate_notification_target_url
from backend.app.routers import auth as auth_router
from backend.app.routers import portal as portal_router
from backend.app.routers import requests as requests_router
from backend.app.routers import status as status_router
from backend.app.security import PASSWORD_POLICY_MESSAGE, validate_password_policy
from backend.app.services import password_reset
@@ -117,6 +118,22 @@ class ServiceStatusTests(unittest.IsolatedAsyncioTestCase):
self.assertIn("credentials", result["message"].lower())
class RequestCacheTests(unittest.TestCase):
def tearDown(self) -> None:
requests_router._detail_cache.clear()
requests_router._failed_detail_cache.clear()
def test_successful_detail_cache_write_clears_prior_failure(self) -> None:
key = "request:123"
requests_router._failure_cache_set(key)
self.assertTrue(requests_router._failure_cache_has(key))
requests_router._cache_set(key, {"id": 123})
self.assertFalse(requests_router._failure_cache_has(key))
self.assertEqual(requests_router._cache_get(key), {"id": 123})
class DatabaseEmailTests(TempDatabaseMixin, unittest.TestCase):
def test_set_user_email_is_case_insensitive(self) -> None:
created = db.create_user_if_missing(