NCEAS / metacatui

MetacatUI: A client-side web interface for DataONE data repositories
https://nceas.github.io/metacatui
Apache License 2.0
42 stars 28 forks source link

infinite update loop for a dataset with two metadata files #2491

Open jeanetteclark opened 4 months ago

jeanetteclark commented 4 months ago

Describe the bug

Found this strange edge case where metacatUI will get stuck in an infinite loop updating metadata documents when there is more than one metadata file in a package.

To Reproduce Steps to reproduce the behavior:

  1. Create a new dataset using metacatUI
  2. Run the following R script
library(dataone)
library(datapack)

d1c <- D1Client("STAGING", "urn:node:mnTestKNB")
resource_map_pid <- "{YOUR RM PID HERE}"

pkg <- dataone::getDataPackage(d1c, resource_map_pid)
emlFile <- system.file("extdata/strix-pacific-northwest.xml", package="dataone")
# add an additional metadata file
metadataObj <- new("DataObject", format="eml://ecoinformatics.org/eml-2.1.1", filename=emlFile)
# add a data file
sourceData <- system.file("extdata/OwlNightj.csv", package="dataone")
sourceObj <- new("DataObject", format="text/csv", filename=sourceData)
pkg <- addMember(pkg, sourceObj, metadataObj)
# Upload changes (new files) to package
uploadDataPackage(d1c, pkg, public = TRUE, accessRules=pkg@sysmeta@accessPolicy, quiet = FALSE)
  1. Go back to MetacatUI. In the dataset listing you'll see two recent datasets, the one you created on the web form and the Strix. Both of thse are associated with the same package. Click on the Strix dataset and edit it:
Screen Shot 2024-07-25 at 5 13 06 PM Screen Shot 2024-07-25 at 5 13 17 PM
  1. Make a minor edit to the title of the strix dataset
  2. Observe metacatUI switch back and forth updating the metadata documents, and look at the version chain for the non-Strix metadata.
Screen Shot 2024-07-25 at 5 14 48 PM

Expected behavior

...not this. I'm not sure what the expected behavior is here since the R code really had a bug in it (it should have replaced the metadata record and not added a new one). But I think theoretically multiple metadata documents is supported in the packaging model.

jeanetteclark commented 4 months ago

I should also add that I'll look into the resource map as well today since its also possible the package datapack created should not be allowed

robyngit commented 3 months ago

Interesting. Thanks for reporting along with a very reproducible example @jeanetteclark !