-
Notifications
You must be signed in to change notification settings - Fork 496
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
Auxiliary File API Enhancements #8237
Auxiliary File API Enhancements #8237
Conversation
I added a reminder to expand on use cases at release time (but also so the build would be re-tried automatically :)). I'll unassign myself so someone can review the code. |
thanks @qqmyers, 👍 for "API will block attempts to create a duplicate auxiliary file" |
Conflicts (from PR IQSS#8192 it seems): src/main/java/edu/harvard/iq/dataverse/api/Access.java
That's odd, testForceReplaceAndUpdate failed with a 500 error according to https://jenkins.dataverse.org/job/IQSS-Dataverse-Develop-PR/job/PR-8237/3/testReport/junit/edu.harvard.iq.dataverse.api/FilesIT/testForceReplaceAndUpdate/ I just ran it locally, individually, and it passed. It might be a recurrence of this issue:
I'll probably push a small commit, maybe to docs, just to see if I can get the test suite passing. |
FWIW: Looks like the 500 error would be from the UpdateDatasetVersionCommand failing - since the test does a replace file right before the metadata update, it could just be a conflict due to indexing still running on the dataset, etc. - i.e. a random race condition that a delay or checking and waiting for the lastindex timestamp to update would fix. |
Whoops, when I merged develop I accidentally deleted the "list by origin" API endpoint. I added it back in 59d0cbb. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall, looks good.
Bugs:
- "Listing Auxiliary Files for a Datafile by Origin" gives a 500 error and NullPointerException if no type is given. You could consider using NullSafeJsonBuilder but whatever solution is fine.
Would appreciate these:
- Yes, it would be nice to have a "list all aux files given a file id" endpoint. Users will know the file id. They may not remember the origin they used.
- I added a few tests in b66fb55 but only for the new "delete" and "list by origin" APIs. It would be nice to have tests for the new "non-tabular files can have aux files" rule and the "duplicate aux files" are prevented rule. Possibly the new error handling could be tested too. Maybe tests around permissions.
Things to think about:
- Various comments I left in the review.
- When should we move the aux file API docs from dev/experimental to prod?
- 404 gives a somewhat confusing "no API endpoint exists" error. This happens for any API endpoint that returns a 404, I think, so it's not unique to this code. It looks like this:
{"status":"ERROR","code":404,"message":"API endpoint does not exist on this server. Please check your code for typos, or consult our API guide at http://guides.dataverse.org.","requestUrl":"http://localhost:8080/api/v1/access/datafile/1441/auxiliary/myApp","requestMethod":"GET"}
src/main/java/edu/harvard/iq/dataverse/AuxiliaryFileServiceBean.java
Outdated
Show resolved
Hide resolved
src/main/java/edu/harvard/iq/dataverse/AuxiliaryFileServiceBean.java
Outdated
Show resolved
Hide resolved
} catch(Exception ex) { | ||
return null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we handle the exception from getResultList somehow?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the exceptions for getResultList(); all indicate real server errors, I've removed the try block so they bubble up to be reported via the API. I also changed the existing getSingleResult() call where one exception (NoResultException) is OK and should return null whereas other exceptions represent a real server error.
Conflicts: src/main/java/edu/harvard/iq/dataverse/api/Access.java
re: main review comment:
Assuming the IT tests pass, I think this is ready to go forward again unless the changes raise further points. |
@qqmyers thanks for all the changes. I haven't looked through them all (and probably will) but I wanted to give you a heads up that AuxiliaryFilesIT is failing with a 500 error. |
Fixed the tests. Also discovered that the original code didn't calculate checksums correctly. Code is now fixed, but all existing entries have bad checksum values. They could be recalculated from the files themselves, but it's not something that can be addressed just by a flyway script. Removing/re-adding files via api would probably work, so a script to find/list all entries and then delete/re-add could be made. Since QDR is only using this in testing, I think Harvard is probably the only place with many aux file entries that need updating. |
storageIO.saveInputStreamAsAux(fileInputStream, auxExtension); | ||
auxFile.setChecksum(FileUtil.checksumDigestToString(di.getMessageDigest().digest()) ); | ||
if (storageIO.isAuxObjectCached(auxExtension)) { | ||
throw new ClientErrorException("Auxiliary file already exists", Response.Status.CONFLICT); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
409 (Conflict) seems slightly exotic for our code base but I guess it's fine.
"For example, you may get a 409 response when uploading a file which is older than the one already on the server resulting in a version control conflict." https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/409
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. I went ahead and merged the latest from develop.
What this PR does / why we need it:
This PR adds a few enhancements to the Aux file API:
Which issue(s) this PR closes:
Closes #8235
Special notes for your reviewer:
Suggestions on how to test this:
As usual, just following the doc examples should be good. Specific things to try would be
Does this PR introduce a user interface change? If mockups are available, please link/include them here: api only
Is there a release notes update needed for this change?: draft provided - this is a tweak to an experimental API so probably nothing that needs to be prominent
Additional documentation: