Fix bug in publishing process #2636
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There is a bug during the publishing process where a shallow reference to the draft
Version.metadatadict is erroneously used for the newly created publishedVersion. Because of this, when we insert new fields into the published metadata during the publishing process, we are also unknowingly adding them into the in-memory draftVersionobject. Then, during the_publish_dandisetservice function, we call.save()on the draftVersionobject, which writes those new fields to the draft version in the DB.I discovered this while testing out #2606, because I was seeing a bug where the release notes would get added to the draft version too (this is visible in the video in that PR's description; after the dandiset is published, notice that the "DRAFT" version in the UI has an icon next to it indicating release notes). This seems to have gone unnoticed due to the
publishedByanddatePublishedfields not being displayed anywhere in the UI, but became obvious with the addition of thereleaseNotesfield.I've confirmed that, out of the 984 draft versions on dandiarchive.org that have been published at least once, 389 of them have the
publishedByanddatePublishedfields in their metadata.