You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've bumped into an error that never happened before upgrading to version 7.6.2.
I'm getting an error saying that an enum class instance is not json serializable. Here's the full error line:
File \"/usr/local/lib/python3.11/json/encoder.py\", line 180, in default\n raise TypeError(f'Object of type {o.__class__.__name__} '\nTypeError: Object of type QueueType is not JSON serializable\n"
and the code generating the error is the following:
# FastAPI endpoint@router.put('/queue')asyncdefupdate_queue(queue_update: Queue):
try:
match=dict(type=queue_update.type, site_key=queue_update.site_key) # <-- the type parameter is of type QueueTypedb.collection('Queue').update_match(match, queue_update, keep_none=False, sync=True) # <-- line raising the error
Any insight on what's happening? A regression?
The text was updated successfully, but these errors were encountered:
Unfortunately, the update_match method (among others, see 7.6.1) had to be refactored, due to their usage of _api/simple HTTP API, which has been long deprecated since ArangoDB 3.4.
The simple queries provided by the /_api/simple endpoint were limited in functionality and internally resorted to AQL queries anyway. Therefore, we kept the driver methods that used to rely on them, but adapted them to use AQL instead. Apart from being safer and up-to-date, users might notice even a performance improvement from this.
Because the filters (e.g. your match dict) have to be part of an AQL query, they are Json serialized now. Normally this shouldn't pose any problems, but there are corner cases, such as with Enum. You'll have to make your Enum Json serializable. There are several ways to go about this, but I would suggest inheriting from str:
Hi there,
I've bumped into an error that never happened before upgrading to version 7.6.2.
I'm getting an error saying that an enum class instance is not json serializable. Here's the full error line:
QueueType
is anEnum
class as follows:and the code generating the error is the following:
Any insight on what's happening? A regression?
The text was updated successfully, but these errors were encountered: