Skip to content

UUID field not serialized #82

@rekt-hard

Description

@rekt-hard

Package version (if known):

Describe the bug

For notifications, I am trying to serialize the draft of a record with the .dumps() method of the record class, such that it can be passed around for a celery task.
When starting the task, I'll get an kombu.exceptions.EncodeError: can not serialize 'UUID' object error. Checking the serialized draft, all fields are fine, except for the versions. The UUID fields of the versions are not dumped as strings but as UUID objects 'next_draft_id': UUID('c0d626f3-84ae-4c19-8205-4dfe546f1323').

in records-resources, UUID fields are explicitly converted to str: https://github.com/inveniosoftware/invenio-records-resources/blob/master/invenio_records_resources/records/api.py#L157-L169
in drafts-resources, this conversion is missing: https://github.com/inveniosoftware/invenio-drafts-resources/blob/master/invenio_drafts_resources/records/systemfields/versions.py#L137-L146

In the json serializer, UUID fields are handled: https://github.com/pallets/flask/blob/41d4f62909bb426c84e9d057151f7d734695320a/src/flask/json/provider.py#L109-L122

Steps to Reproduce

To be added

Expected behavior

To serialize a UUID field, when it is passed to a task, no matter the serializer selected.

Screenshots (if applicable)

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions