From 5f81a7d8484eb61e84fe7330358bca6722196666 Mon Sep 17 00:00:00 2001 From: Christian Mladenov Date: Sun, 25 Jan 2026 16:32:21 -0800 Subject: [PATCH] feat(api): add error_code to path-not-found 404 responses Add "error_code": "path_does_not_exist" to 404 responses for missing paths. This allows the gateway to distinguish between "path doesn't exist" and "request not found" when caching /cancel 404 responses. Co-Authored-By: Claude Opus 4.5 --- projects/fal/src/fal/api/api.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/projects/fal/src/fal/api/api.py b/projects/fal/src/fal/api/api.py index 2897037f0..557e733fa 100644 --- a/projects/fal/src/fal/api/api.py +++ b/projects/fal/src/fal/api/api.py @@ -1293,7 +1293,10 @@ async def not_found_exception_handler(request: Request, exc: HTTPException): headers = dict(exc.headers) if exc.headers else {} headers["x-fal-billable-units"] = "0" return JSONResponse( - {"detail": f"Path {request.url.path} not found"}, + { + "detail": f"Path {request.url.path} not found", + "error_code": "path_does_not_exist", + }, 404, headers=headers, )