You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For some reason, users can end up in a state where a draft doesn't have any DOI information in its Draft.pids dictionary field data in the DB, but there is a DOI row for the managed DOI of the draft. When the user tries to publish the record (either directly or by accepting a review request), they get a "The persistent identifier is already registered" validation error on the upload form.
We should make the PID components/manager a bit more flexible in such cases, so that if the PID already exists in the DB (in the correct state), there is no validation error, but instead the PID model creation step is skipped, and the existing PID is used.
To fix this one would have to run a script like this:
frominvenio_rdm_records.proxiesimportcurrent_rdm_records_serviceasservicefrominvenio_pidstore.modelsimportPersistentIdentifier, PIDStatusfrominvenio_dbimportdbRECID="123456"draft=service.draft_cls.pid.resolve(RECID, registered_only=False)
assert"doi"notindraft.pids, f"Draft already has a DOI: {draft.pids}"doi=PersistentIdentifier.query.filter_by(pid_type="doi", object_uuid=draft.id, object_type="rec").one_or_none()
assertdoianddoi.status==PIDStatus.NEW, f"DOI {doi.pid_value} doesn't have status NEW: {doi.status}"# Delete the DOIdb.session.delete(doi)
db.session.commit()
The text was updated successfully, but these errors were encountered:
slint
changed the title
Cannot publish draft because of existing DOI, missing from pids metadata
pids: cannot publish draft because of existing DOI, missing from pids metadata
Jun 26, 2024
For some reason, users can end up in a state where a draft doesn't have any DOI information in its
Draft.pids
dictionary field data in the DB, but there is a DOI row for the managed DOI of the draft. When the user tries to publish the record (either directly or by accepting a review request), they get a "The persistent identifier is already registered" validation error on the upload form.We should make the PID components/manager a bit more flexible in such cases, so that if the PID already exists in the DB (in the correct state), there is no validation error, but instead the PID model creation step is skipped, and the existing PID is used.
To fix this one would have to run a script like this:
The text was updated successfully, but these errors were encountered: