ynput / ayon-backend

Server codebase with API access to AYON
Apache License 2.0
22 stars 16 forks source link

Handle empty response when returning cached 'nothing to do' from enroll #402

Closed martastain closed 1 month ago

martastain commented 1 month ago

This pull request includes a small but important change to the enroll endpoint. The change ensures that an EmptyResponse is returned if the cached result is not available.

martastain commented 1 month ago

Any reason you're not doing: cached_result.get("result", EmptyResponse()) if for whatever the "result" is still empty in some other meaningful way?

Yep, you're right. I'll clean it up

Also, does cached_result.get("result") actually return a EnrollResponseModel? Because it seems to just be returning the JSON result from Redis.get_json() which looking at the code seems to return json_loads for example?

Fastapi really doesn't care here. The result from orjson.loads is a plain dict, but it will work as long as it matches the response model.