Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pids: cannot publish draft because of existing DOI, missing from pids metadata #1757

Open
slint opened this issue Jun 26, 2024 · 1 comment
Labels

Comments

@slint
Copy link
Member

slint commented 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:

from invenio_rdm_records.proxies import current_rdm_records_service as service
from invenio_pidstore.models import PersistentIdentifier, PIDStatus
from invenio_db import db

RECID = "123456"

draft = service.draft_cls.pid.resolve(RECID, registered_only=False)
assert "doi" not in draft.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()
assert doi and doi.status == PIDStatus.NEW, f"DOI {doi.pid_value} doesn't have status NEW: {doi.status}"

# Delete the DOI
db.session.delete(doi)
db.session.commit()
@slint 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
Copy link
Contributor

This issue was automatically marked as stale.

@github-actions github-actions bot added the stale label Aug 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant