From 516996d6f310a76f3387e59b87e7a8e1ff19c919 Mon Sep 17 00:00:00 2001 From: Felippe Costa Date: Sun, 8 Feb 2026 15:01:19 -0300 Subject: [PATCH 1/2] fix: return 400 instead of 500 for validation errors --- app/api/routes/validate.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/app/api/routes/validate.py b/app/api/routes/validate.py index 0cf393c..3825918 100644 --- a/app/api/routes/validate.py +++ b/app/api/routes/validate.py @@ -1,5 +1,5 @@ import signedshot -from fastapi import APIRouter, Depends, File, UploadFile, status +from fastapi import APIRouter, Depends, File, HTTPException, UploadFile, status from app.schemas.validate import ( CaptureTrustInfo, @@ -41,9 +41,15 @@ async def validate_media( sidecar_json = (await sidecar.read()).decode("utf-8") jwks = jwk_service.get_jwks() - result = signedshot.validate_with_jwks( - sidecar_json, media_bytes, jwks.model_dump_json() - ) + try: + result = signedshot.validate_with_jwks( + sidecar_json, media_bytes, jwks.model_dump_json() + ) + except (ValueError, Exception) as e: + raise HTTPException( + status_code=status.HTTP_400_BAD_REQUEST, + detail=f"Validation failed: {e}", + ) # Convert to response model capture_trust = result.capture_trust From 1e31fde5f8e29ba74d43f0a3b468e39b1737ad39 Mon Sep 17 00:00:00 2001 From: Felippe Costa Date: Sun, 8 Feb 2026 15:03:56 -0300 Subject: [PATCH 2/2] fix: lint --- app/api/routes/validate.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/api/routes/validate.py b/app/api/routes/validate.py index 3825918..84ef13d 100644 --- a/app/api/routes/validate.py +++ b/app/api/routes/validate.py @@ -49,7 +49,7 @@ async def validate_media( raise HTTPException( status_code=status.HTTP_400_BAD_REQUEST, detail=f"Validation failed: {e}", - ) + ) from e # Convert to response model capture_trust = result.capture_trust