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

500 server error when adding a dataset in dataverse where default template has no associated terms #8599

Closed
scolapasta opened this issue Apr 12, 2022 · 11 comments · Fixed by #8789
Assignees

Comments

@scolapasta
Copy link
Contributor

scolapasta commented Apr 12, 2022

This was reported by a user via RT:
They click Add Dataset on their dataverse and get a 500 error page.

The reason is that a null pointer is being thrown. After some investigation, it turns out that the dataset has a default template with no associated terms (termsofuseandaccess_id is null on the template) and that in turn causes the null pointer on line 163 of DatasetUtil:
License license = dsv.getTermsOfUseAndAccess().getLicense();

The workaround we suggested is to go and edit the template and associate terms (even if empty) to the template.

I did try to reproduce on demo with a new dataverse, but I wasn't able to create a template with no terms (I tried briefly) so it's possible that can't be done anymore and only affects some legacy templates (in prod, there were 89 such templates, 48 of which were set as a default template).

The fix could be one of:
• db update to create empty terms for any existing templates (and verify there is no way to create any such new ones)
• change line 163 to make sure dsv.getTermsOfUseAndAccess() is not null before calling getLicense()

@scolapasta
Copy link
Contributor Author

Looks like we may need to opt for some aspect of 1 or more complicated 2) as right now you also cannot edit the terms on these legacy templates (an error is thrown).

@scolapasta
Copy link
Contributor Author

So, to fix the issue for the one that was from the RT issue, I:
• Created a new dummy template (through ui)
• through db set the associated terms of the existing template to the ones created for the dummy template, and set the dummy template terms to null.
• deleted dummy template (through ui)

Note that means the template now has a cc0 license, so this would need to be reviewed to make sure that is what is desired. If not, the dataverse admin can then change it through the UI.

@qqmyers
Copy link
Member

qqmyers commented Apr 12, 2022

From some quick testing at QDR, I don't think you can create new templates that don't have a termsofuseandaccess so this might be a job for flyway. FWIW: I played with this commit to start - basically null check TermsOfUseAndAccess 'everywhere' it is being used to get the license (everywhere doesn't include in the xhtml files). Without a flyway, this would cause users of an old template to get custom terms instead of the default license though.

@mreekie
Copy link

mreekie commented Apr 25, 2022

Priority - the current work around is a manual fix. We are getting RT tickets on this issue so this is a production impacting issue. It will likely impact other dataverse implementations outside of harvard.edu

@mreekie
Copy link

mreekie commented Apr 27, 2022

sprint

  • writeup a db script
  • release to community.
  • small

@scolapasta scolapasta self-assigned this Apr 29, 2022
@scolapasta
Copy link
Contributor Author

scolapasta commented Apr 29, 2022

This query can be used to fix individual templates. Eventually, will see if possible to handle problematic templates in bulk.

Note this sets the fileaccessrequest in the template to false and the license_id to 1. We should verify those values (but we need to choose something for both, and that is the default if you just create a new template from the UI).

with _insert as 
(
insert into termsofuseandaccess (fileaccessrequest, license_id) values (false, 1)
returning id 
)
update template set termsofuseandaccess_id =  (select id from _insert)
where id = XXX and termsofuseandaccess_id is null;

@scolapasta
Copy link
Contributor Author

scolapasta commented Apr 30, 2022

Foxing multiple in one query is a little tricky, but this query at least can be used multiple times (the last one was id specific) - this one will grab the first one without a terms, create a new terms, and links them. i.e. if you run a 2nd time, it will then grab the next one without terms...

with _sel as 
(
select id from template where termsofuseandaccess_id is null limit 1
), _insert as 
(
insert into termsofuseandaccess (fileaccessrequest, license_id) values (false, 1)
returning id 
)
update template set termsofuseandaccess_id =  (select id from _insert)
from _sel where template.id=_sel.id;


@scolapasta
Copy link
Contributor Author

Ah, actually the way to do it is in reverse - rather than first insert and then update (the problem being that the update then needs to take from a stack), you first update, then insert. This uses the "stacking" inherent in nextval.

(I thought you might have to disable, then reenable the foreign key, but it seems to work without that, probably because it's all handled in the one query).

with  _update as 
(
update template set termsofuseandaccess_id =  nextval('termsofuseandaccess_id_seq' )
where termsofuseandaccess_id is null
returning termsofuseandaccess_id
)
insert into termsofuseandaccess (id, fileaccessrequest, license_id) (select termsofuseandaccess_id, false, 1 from _update)




@mreekie
Copy link

mreekie commented May 11, 2022

Sprint

  • 8599: Still small; I just need to find time to make the flyway script / release notes

@lenwiz lenwiz changed the title 500 server error when adding a a dataset in dataverse where default template has no associated terms 500 server error when adding a dataset in dataverse where default template has no associated terms May 16, 2022
@mreekie
Copy link

mreekie commented May 25, 2022

@mreekie
Copy link

mreekie commented Jun 8, 2022

Sprint:

  • pm.sprint.2022_05_25 ended WIP

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