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

Cannot create Dataverse collection after editing required metadata fields #8236

Closed
djbrooke opened this issue Nov 10, 2021 · 5 comments · Fixed by #8246
Closed

Cannot create Dataverse collection after editing required metadata fields #8236

djbrooke opened this issue Nov 10, 2021 · 5 comments · Fixed by #8246

Comments

@djbrooke
Copy link
Contributor

djbrooke commented Nov 10, 2021

What steps does it take to reproduce the issue?

  • Add a new Dataverse collection
  • Enter in the required content (alias, type, etc.)
  • Under “Metadata Fields” deselect “Use metadata fields from Harvard Dataverse” (or whatever Dataverse installation you're using)
  • Expand citation metadata
  • Make all the fields under “Related Publication” required instead of optional (See screenshot)
  • Try to save the page

When does this issue occur?

When creating a new Dataverse collection and trying to edit the required fields.

Which page(s) does it occurs on?

https://dataverse.harvard.edu/dataverse.xhtml

What happens?

The page fails to save and an error is shown:

Error – Command edu.harvard.iq.dataverse.engine.command.impl.CreateDataverseCommand@11c92da3 failed: Transaction aborted If you believe this is an error, please contact Harvard Dataverse Support for assistance.

From the logs, it also appears there are some SEVERE messages related to duplicate key errors around this time.

To whom does it occur (all users, curators, superusers)?

Anyone with Dataverse collection create permissions.

What did you expect to happen?

I expected a new Dataverse collection to be created and I expected those fields under related publication to be required for new datasets.

Which version of Dataverse are you using?

5.6 (dataverse.harvard.edu), but this occurs in 5.8 (demo.dataverse.org) as well.

Any related open or closed issues to this bug report?

I looked, and will take another look, but none popped out.

Screenshots:

Screen Shot 2021-11-10 at 10 08 32 AM

@pdurbin
Copy link
Member

pdurbin commented Nov 10, 2021

On develop (13c334f) I get a slightly different error message (same failure to save): This dataverse was not able to be created. – Please contact Root Support for assistance. Date/Time: 2021-11-10 16:53:55 Server: localhost

Here's a stacktrace (duplicate key errors, as reported above): stacktrace.txt

Errors like this: Caused by: org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "unq_dataversefieldtypeinputlevel_0"

@qqmyers
Copy link
Member

qqmyers commented Nov 10, 2021

Haven't completely parse this code, which is in a loop over the set of fields:

if (!dsft.isHasParent() && dsft.isInclude()) {
addRequiredInputLevels = !dsft.isRequired();
}
if (dsft.isHasParent() && dsft.getParentDatasetFieldType().isInclude()) {
addRequiredInputLevels = !dsft.isRequired() || !dsft.getParentDatasetFieldType().isRequired();
}
if (addRequiredInputLevels) {
listDFTIL.add(new DataverseFieldTypeInputLevel(dsft, dataverse,true, true));
//also add the parent as required
if (dsft.isHasParent()) {
listDFTIL.add(new DataverseFieldTypeInputLevel(dsft.getParentDatasetFieldType(), dataverse,true, true));
}
}
}
but it looks to me like, if you set more than one child to required, you will get multiple DataverseFieldTypeInputLevel objects added to the list for the parent, causing the duplicate key error. Filtering/only adding to the list if the parent isn't already in it at line 627 might be a fix.

@qqmyers
Copy link
Member

qqmyers commented Nov 10, 2021

Did a quick test - only changing one child field works, so - that

  • is consistent with the idea above as to what the issue is, and
  • means that a work-around is to create the dataverse and then edit a couple more times to add one child at a time.

@pdurbin pdurbin self-assigned this Nov 17, 2021
@pdurbin
Copy link
Member

pdurbin commented Nov 18, 2021

means that a work-around is to create the dataverse and then edit a couple more times to add one child at a time.

Unfortunately, from poking around on develop (4ba22f4) adding one child at a time doesn't work.

Here's what I did:

  • Create dataverse, save.
  • Edit dataverse, change "Other ID Agency" to required (subfield of "Other ID"), save.
  • Edit dataverse, change "Other ID Identifier" as required (subfield of "Other ID"), save.
  • BOOM! PSQLException: ERROR: duplicate key value violates unique constraint "unq_dataversefieldtypeinputlevel_0"

So my understanding of the bug is "two subfields of the same parent cannot be required". I can reproduce this on https://demo.dataverse.org

Filtering/only adding to the list if the parent isn't already in it at line 627 might be a fix.

I tried this but then "required" wasn't enforced. I'm not sure why.

I wonder if pull request #7608 is where this behavior was introduced and will probably ask @scolapasta about it.

It was merged as part of 5.4 so I'll probably ask @donsizemore to test https://dataverse.unc.edu which is running 5.3. Update: I tried this and could not replicate the issue on the UNC installation.

Here's a screenshot of partway through the steps above (about to change "Other ID Identifier" to required):

Screen Shot 2021-11-18 at 11 54 31 AM

@pdurbin
Copy link
Member

pdurbin commented Nov 18, 2021

Filtering/only adding to the list if the parent isn't already in it at line 627 might be a fix.

I tried this but then "required" wasn't enforced. I'm not sure why.

I was doing this wrong. @qqmyers was right. It seems like if we ensure the parent is only added once (in my quick test I wasn't adding the parent at all, whoops) then we can have multiple required subfields again. I just made pull request #8246.

pdurbin added a commit that referenced this issue Nov 19, 2021
pdurbin added a commit that referenced this issue Dec 1, 2021
This reverts commit 291dbbe.

The original, non-set approach actually works.
kcondon added a commit that referenced this issue Dec 3, 2021
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 a pull request may close this issue.

3 participants