Problem
Every router endpoint catches Exception and returns HTTP 400:
except Exception as e:
raise HTTPException(status_code=400, detail=f"Failed to ...: {str(e)}") from e
This masks actual server errors (e.g., KeyError, TypeError, AttributeError) as "bad request" responses when they should be 500 Internal Server Error. It also swallows tracebacks, making debugging difficult.
Suggested Fix
- Catch specific expected exceptions (e.g.,
ValueError, KeyError for invalid platform) and return 400.
- Let unexpected exceptions propagate to FastAPI's default 500 handler (or use a custom exception handler).
- Consider structured error responses with error codes for better client-side handling.
Problem
Every router endpoint catches
Exceptionand returns HTTP 400:This masks actual server errors (e.g.,
KeyError,TypeError,AttributeError) as "bad request" responses when they should be 500 Internal Server Error. It also swallows tracebacks, making debugging difficult.Suggested Fix
ValueError,KeyErrorfor invalid platform) and return 400.