gramps-project / gramps-web-api

A RESTful web API for Gramps - backend of Gramps Web
https://www.grampsweb.org
GNU Affero General Public License v3.0
84 stars 46 forks source link

Error when running check & repair #520

Open DavidMStraub opened 4 months ago

DavidMStraub commented 4 months ago
[2024-07-10 18:23:05,634: ERROR/ForkPoolWorker-7] Task gramps_webapi.api.tasks.check_repair_database[e1958ffb-55cc-4533-afd7-397f53ba4e76] raised unexpected: AttributeError("'Tag' object has no attribute 'gramps_id'")
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/dist-packages/celery/app/trace.py", line 453, in trace_task
    R = retval = fun(*args, **kwargs)
                 ^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/gramps_webapi/util/celery.py", line 20, in __call__
    return self.run(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/gramps_webapi/api/tasks.py", line 338, in check_repair_database
    return check_database(db_handle, progress_cb=progress_callback_count(self))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/gramps_webapi/api/check.py", line 123, in check_database
    checker.check_backlinks()
  File "/usr/local/lib/python3.11/dist-packages/gramps/plugins/tool/check.py", line 1416, in check_backlinks
    {"gid": pri_obj.gramps_id, "cls": key[0], "cls2": item[0]},
            ^^^^^^^^^^^^^^^^^
AttributeError: 'Tag' object has no attribute 'gramps_id'
Nick-Hall commented 4 months ago

A Tag is a TableObject rather than a PrimaryObject so it doesn't have a gramps_id.

DavidMStraub commented 4 months ago

Right, but I believe there error is in Gramps core: https://github.com/gramps-project/gramps/blob/master/gramps/plugins/tool/check.py#L1416

It assumes a referenced object is a primary object, but it can be a tag as well.