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: skip modifications when no data is passed #1139

Merged
merged 2 commits into from
Jan 20, 2023

Conversation

slint
Copy link
Member

@slint slint commented Dec 6, 2022

Closes zenodo/zenodo-rdm#99.

depends on inveniosoftware/react-invenio-deposit#612
❤️ Thank you for your contribution!

Description

Please describe briefly your pull request.

Checklist

Ticks in all boxes and 🟢 on all GitHub actions status checks are required to merge:

Third-party code

If you've added third-party code (copy/pasted or new dependencies), please reach out to an architect.

Reminder

By using GitHub, you have already agreed to the GitHub’s Terms of Service including that:

  1. You license your contribution under the same terms as the current repository’s license.
  2. You agree that you have the right to license your contribution under the current repository’s license.

if "pids" in data:
pids = data.get("pids", {})
else:
pids = record.pids or {}
Copy link
Member

@zzacharo zzacharo Dec 14, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you test the use case (currently via the UI):

  • Fill in an external pid
  • Save
  • Change your answer from "yes" to "no" without reserving a doi
  • Save again. Payload sent is skipping the pids key entirely and the UI expects the backend to reserve one when the record is published!

pids = data.get("pids", {})
self.service.pids.pid_manager.validate(pids, record, errors)
record.pids = pids
pids_data = record.pids or {} # current pids state
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you test what I described here #1139 (comment) ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you are right, this currently breaks in the upload form. I.e. you publish the record with the external DOI that was entered and saved in steps 1 + 2 (even though you choose "No" and click Save).

To move forward, we can either:

  1. Skip this change (there are some implications in Zenodo Legacy REST API PR for that to work, but it's possible)
  2. Change in the upload form if the user selects "No" to serialize an empty pids: {} on the next "Save".
  3. Accept this edge case bug for now until we have a clear vision on what to do with PUT semantics

record.pids = pids
pids_data = record.pids or {} # current pids state
if "pids" in data: # there is new input data for PIDs
pids_data = data.get("pids", {})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
pids_data = data.get("pids", {})
pids_data = data["pids"]

record.pids = pids
pids_data = record.pids or {} # current pids state
if "pids" in data: # there is new input data for PIDs
pids_data = data.get("pids", {})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
pids_data = data.get("pids", {})
pids_data = data["pids"]

@zzacharo zzacharo merged commit bf00eb2 into inveniosoftware:master Jan 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

migrate legacy API to new instance
3 participants