ebhy/budgetml

[BUG] Better alignment with REST API: send 500 not 400 if predictor couldn't get loaded

atemate opened this issue ยท 1 comments

Describe the bug
Hi! first of all, thanks for such a neat tool! ๐ŸŽ‰

It's not a bug, I just thought that sending HTTP 400 is not good when the predictor couldn't get loaded (all /predict* routes):

@app.post("/predict/")
async def predict(request: Request,
_: str = Depends(verify)) -> Response:
global PREDICTOR
if PREDICTOR is None:
raise HTTPException(
status_code=400,
detail="The predictor could not be loaded. Please check the logs "
"for more detail.",
)

I think, it's better to use a 5XX server-side error:

  • HTTP 400 means that there was a client error (e.g., malformed request syntax, invalid request message framing, or deceptive request routing).
  • HTTP 500 means that the server encountered an unexpected condition that prevented it from fulfilling the request. This error response is a generic "catch-all" response. Usually, this indicates the server cannot find a better 5xx error code to response.

Good catch! I pushed it now with this commit.. Also directly updated the base image so that it gets reflected on future runs (Not the most professional but I did not want to wait for the next release of BudgetML to accommodate this small request ๐Ÿ‘ )