Skip to content

Tests failing with Gramps 6.0 due to issue with metadata #631

@DavidMStraub

Description

@DavidMStraub

I was puzzled for an hour trying to find out why tests fail with this stack trace when loading a new database:

/home/david/.venv/gramps6/lib/python3.12/site-packages/gramps/gen/db/generic.py:749: in load
    self.name_formats = self._get_metadata("name_formats")
/home/david/.venv/gramps6/lib/python3.12/site-packages/gramps/plugins/db/dbapi/dbapi.py:399: in _get_metadata
    return self.serializer.metadata_to_object(row[0])
/home/david/.venv/gramps6/lib/python3.12/site-packages/gramps/gen/lib/serialize.py:157: in metadata_to_object
    doc = string_to_dict(string)

I finally found the issue.

The change introduced by @prculley in gramps-project/gramps#1992 creates all metadata in blob format for backwards compatibility. This will obviously leave the JSON columns empty (NULL). Now, if you load this database for the first time, when it tries to load metadata (e.g. name_formats), it finds a row and tries to deserialize it, but orjson fails to decode None.

Image

I think the reason nobody noticed until now is that, as soon as you call .close() on the db, it will store all metadata also in JSON format.

To resolve this, I think the easiest solution is to _set_all_metadata also for the JSON serializer after doing it for the blobs.

The release of Gramps Web API for Gramps 6.0 is blocked until this issue is resolved in Gramps.

CC @dsblank, @Nick-Hall

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions