feat: prevent draft creation for unchanged dataset metadata - #12452
feat: prevent draft creation for unchanged dataset metadata#12452AnneGerlach wants to merge 3 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. |
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 🌷 )