From e1362cea4be97525fde5b4d2ace3cb8a19fa952c Mon Sep 17 00:00:00 2001 From: irl Date: Tue, 19 May 2026 13:01:41 +0100 Subject: [PATCH] fix: status codes for snapshots router errors --- src/snapshots/router.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/snapshots/router.py b/src/snapshots/router.py index bb98562..a7d5157 100644 --- a/src/snapshots/router.py +++ b/src/snapshots/router.py @@ -21,7 +21,10 @@ router = APIRouter() ) def context(auth: ApiKey, url: str = "https://www.bbc.com/russian/articles/ckgeey4dqgxo"): if settings.ENVIRONMENT.is_debug or auth: - return SnapshotCamera(url).get_context() + ctx = SnapshotCamera(url).get_context() + if ctx is None: + raise HTTPException(status.HTTP_404_NOT_FOUND, detail="No configuration for URL") + return ctx raise HTTPException(status.HTTP_404_NOT_FOUND) @@ -33,7 +36,7 @@ def context(auth: ApiKey, url: str = "https://www.bbc.com/russian/articles/ckgee def parse(auth: ApiKey, url: str = "https://www.bbc.com/russian/articles/ckgeey4dqgxo"): if settings.ENVIRONMENT.is_debug or auth: return SnapshotCamera(url).render() - raise HTTPException(status.HTTP_404_NOT_FOUND) + raise HTTPException(status.HTTP_403_FORBIDDEN) @router.get( @@ -54,4 +57,4 @@ def snap( background_tasks.add_task(generate_snapshot, s.id) if s: return {"url": s.link} - return status.HTTP_403_FORBIDDEN + raise HTTPException(status.HTTP_404_NOT_FOUND)