gramps-web-api icon indicating copy to clipboard operation
gramps-web-api copied to clipboard

Gramps XML export (and thus synchronization) can fail in case of corrupted objects

Open DavidMStraub opened this issue 1 year ago • 14 comments

If some objects contain invalid data, such as None as handle, Gramps XML export can fail, which prevents backup as well as synchronization. We should have something like a "repair database" endpoint.

DavidMStraub avatar Jan 28 '24 14:01 DavidMStraub

The best solution would of course be to just use the Gramps built-in check & repair tool, however that does not work since it also tries to check media checksums, which generally will not for in Web API because media files are managed differently.

~So the best solution for now in my opinion would be to create a new addon that is a ligher (or customizable) version of check.py, but not reimplementing any of the logic.~

On second though, I think an addon is overkill - we can just create a background task that runs the functions in the check and repair tool except media checksums.

DavidMStraub avatar Jan 28 '24 14:01 DavidMStraub

Example traceback:

  File "/usr/lib/python3/dist-packages/gramps/plugins/export/exportxml.py", line 179, in write
    self.write_xml_data()
  File "/usr/lib/python3/dist-packages/gramps/plugins/export/exportxml.py", line 313, in write_xml_data
    self.write_source(source,2)
  File "/usr/lib/python3/dist-packages/gramps/plugins/export/exportxml.py", line 616, in write_source
    self.write_media_list(source.get_media_list(), index+1)
  File "/usr/lib/python3/dist-packages/gramps/plugins/export/exportxml.py", line 1129, in write_media_list
    self.g.write('%s<objref hlink="%s"' % (sp,"_"+mobj_id))
                                              ~~~^~~~~~~~
TypeError: can only concatenate str (not "NoneType") to str

DavidMStraub avatar Jan 28 '24 20:01 DavidMStraub

To be confirmed whether this is actually fixed.

DavidMStraub avatar Feb 03 '24 15:02 DavidMStraub

Confirmed by the user that the issue is not fixed - media references with ref None still cause this error after running check & repair.

DavidMStraub avatar Feb 14 '24 16:02 DavidMStraub