feat: prevent draft creation for unchanged dataset metadata - #12452
feat: prevent draft creation for unchanged dataset metadata#12452AnneGerlach wants to merge 5 commits into
Conversation
| } | ||
|
|
||
| boolean updateDraft = ds.getLatestVersion().isDraft(); | ||
| DatasetVersion latestVersion = ds.getLatestVersion(); |
There was a problem hiding this comment.
Could you add a release note explaining the change
|
@AnneGerlach When I tried this, changing the dataset contact email, it was treated as a no-op Before: Here is what I sent: Nothing changed when I get the draft: Without this PR the email value gets updated |
You're right. It seems this approach of simply re-using the Since
I've added examples for these to the To fix this, the change detection needs to be reworked to be based on raw values, not display values. |
|
As a next step, I temporarily disabled no-op detection and added a comprehensive DatasetsIT test documenting the current behavior of the update-draft API (PUT Note that this may have unearthed some unintended behaviour, or at least I'm not sure if it's intended, which is that it's possible for users to update the following DatasetVersion fields when the API is used to create a new draft:
See here: 641b418#diff-f7f8c09756ce44634bf7d9a243e628166a608079fffe7cd71f77f56f949114f6R7674 Confirmed that the new test passes with no-op detection disabled. |
What this PR does / why we need it:
🎫 Closes: #12376
This PR prevents Dataverse from creating or updating a draft version when metadata uploaded via
PUT /api/datasets/{id}/versions/:draftis semantically identical to the existing dataset version.Previously, repeated uploads of unchanged metadata created unnecessary draft versions. This was particularly problematic for automated synchronization workflows, which had to implement their own comparison logic before submitting updates.
The implementation reuses the existing
DatasetVersionDifferencelogic to detect unchanged metadata and terms updates and skips draft creation or update when no effective changes are detected.Changes
Added a no-op check before draft creation and draft update in
PUT /api/datasets/{id}/versions/:draftReused the existing
DatasetVersionDifferenceimplementation to detect unchanged metadata and terms updatesSkipped draft creation/update and returned the existing dataset version when no effective changes are detected
Added integration tests covering both scenarios:
Suggestions on how to test this:
Run tests:
mvn test -Dtest=DatasetsTest,DatasetsITor tests manually:
Test no-op metadata update
dataverseAdminTest changed metadata
# Modify metadata in the file e.g. nano latestVersion.jsonSpecial notes for your reviewer:
Thanks for reviewing 🌻 (and special thanks to @vera for reviewing beforehand 🌷 )