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

IQSS/10324-fix granting file access w/o request #10325

Conversation

qqmyers
Copy link
Member

@qqmyers qqmyers commented Feb 15, 2024

What this PR does / why we need it: To fix granting file access when there was no access request.

At QDR, this appears to be due to an npe:

Caused by: java.lang.NullPointerException: Cannot invoke "edu.harvard.iq.dataverse.FileAccessRequest.setStateGranted()" because "far" is null
        at edu.harvard.iq.dataverse.ManageFilePermissionsPage.grantAccess(ManageFilePermissionsPage.java:425)

Digging in the code a bit, it looks like a bug introduced with the guestboook-at-request PR: As of that PR, requests are not deleted when granted, they are now given the state granted. At the line in question, the code is looking for a request in the created state associated with the file, so if no request exists, it fails. That should mean that when granting access for one file w/o a request existing (didn't test), it would succeed but the success message/page update would fail. With more than one file, the files after the first access isn't granted.

Which issue(s) this PR closes:

Closes #10324

Special notes for your reviewer:

Suggestions on how to test this: See the issue and above. Regression testing - it should also work if someone requested access first.

Does this PR introduce a user interface change? If mockups are available, please link/include them here:

Is there a release notes update needed for this change?:

Additional documentation:

@coveralls
Copy link

Coverage Status

coverage: 20.261% (-0.001%) from 20.262%
when pulling fbaec85 on QualitativeDataRepository:IQSS/10324-grant_file_access_without_request
into f456e51 on IQSS:develop.

@scolapasta scolapasta self-assigned this Feb 15, 2024
Copy link
Member

@pdurbin pdurbin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't tested the code but this is a very straightforward null check. Approved.

@scolapasta scolapasta removed their assignment Feb 20, 2024
@cmbz cmbz added the Size: 3 A percentage of a sprint. 2.1 hours. label Feb 22, 2024
@stevenwinship stevenwinship self-assigned this Mar 6, 2024
@stevenwinship
Copy link
Contributor

stevenwinship commented Mar 6, 2024

@qqmyers @pdurbin

QA:
I tested multiple restricted files with a few requests which now passes (no null pointer exception).
I noticed a few other failures that may have nothing to do with this fix but wanted to check.
After granting access to a few of the requested files I then went to grant access to all the files. I received errors due to the fact that some of the grants were already allowed thus giving duplicate key errors from the DB.
Edit: it was the assign role that threw the exception since the role was already assigned in the DB.

See screenshots and stack trace.

Screenshot 2024-03-06 at 2 04 42 PM
Screenshot 2024-03-06 at 2 02 37 PM
stacktrace.txt

@stevenwinship
Copy link
Contributor

I did verify that I had access to all files even though I saw the error in the UI for the file that was previously granted access

@qqmyers
Copy link
Member Author

qqmyers commented Mar 7, 2024

@stevenwinship - is the error you see also in the main codebase? It's hard to see how this PR could change things, but I could image it is an existing bug. If it is unique to this PR I can look again. If it is also in develop already, I'd suggest we start a new issue.

@stevenwinship stevenwinship merged commit 6b9836d into IQSS:develop Mar 11, 2024
11 checks passed
@pdurbin pdurbin added this to the 6.2 milestone Mar 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Size: 3 A percentage of a sprint. 2.1 hours.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

When granting file permissions (for a group), only one file permission is granted
6 participants