blitz_api icon indicating copy to clipboard operation
blitz_api copied to clipboard

Error cases while fetching warmup data for new SSE clients aren't handled properly

Open fusion44 opened this issue 1 year ago • 1 comments

Currently, the warm-up code assumes that a BaseModel will be returned at all times. Actually an HTTPException can be returned on error.

code: https://github.com/fusion44/blitz_api/blob/b7e9ae29fbcb72b85dc4dea53262c889e82177e8/app/main.py#L303

refs https://github.com/raspiblitz/raspiblitz/issues/4437

fusion44 avatar Feb 25 '24 07:02 fusion44

If something happend during fetching of the warm-up data the log files will now properly print the error:

Feb 25 08:27:58 python[2332042]: 2024-02-25 08:27:58 | ❌ | main.py:290 | Error while fetching warmup_data for system_info: 410: Something bad happened

In this example, the code raises the following exception.

        raise HTTPException(status.HTTP_410_GONE, detail="Something bad happened")

The client will receive an event with the following data:

event: system_info
data: {"error": "410: Something bad happened"}

@cstenglein You might have to add a code path for this case. Is this OK client side or would you prefer the error format like this:

event: system_info
data: {
  "error": {
    "status": 410,
    "message":  "Something bad happened"
   }
}

fusion44 avatar Feb 25 '24 08:02 fusion44