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.

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
I was puzzled for an hour trying to find out why tests fail with this stack trace when loading a new database:
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, butorjsonfails to decodeNone.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_metadataalso 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