Repository navigation
File erase post instead of delete - #12939
Draft
janvanmansum wants to merge 17 commits into
Draft
janvanmansum wants to merge 17 commits into
janvanmansum wants to merge 17 commits into
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this PR does / why we need it:
DELETE /api/files/{id}/eraserequires a JSON body. In a freshly created development container, Payara answered everyDELETErequest with a body with an empty 400 response, before it reached Dataverse. The settingserver.network-config.protocols.protocol.http-listener-1.http.allow-payload-for-undefined-http-methodswasfalsethere. After it was set totrue, the API worked.This PR changes the endpoint to
POST /api/files/{id}/erase, for both steps, with the same body and responses. No Payara setting is needed for that.HTTP does not define a meaning for a body in a
DELETErequest and advises against relying on it (RFC 9110, section 9.3.5):So even if Payara accepts the body, a proxy or load balancer in front of it may reject or change the request. See also:
DELETErequests "shouldn't contain a body".DELETE, a request body "is permitted but does not have well-defined semantics and SHOULD be avoided if possible". The OpenAPI document that Dataverse generates onFileErasehas no request body for this endpoint.GET,HEADandDELETEas methods for which the specification does not clearly state whether they support a payload.POSTfits, as the server processes the body. The file resource also remains: the content is erased, but theDataFileis kept and aFileErasureis added.Which issue(s) this PR closes:
None. This is a change to the
FileErasebranch.Special notes for your reviewer:
DELETEis no longer supported for this path. The branch has not been merged, so there is no released API to keep compatible.Content-Type: application/json. The commands in the guide did not set it, socurl -dsent the form type. For aPOSTrequest the servlet container may parse such a body as form parameters. With@Consumes, a wrong type is rejected clearly.DELETE, because the reason (which may contain GDPR details) and the token would end up in access logs.FileErase-delete-after-commitandFileErase-bind-confirmation-tokenchange nearby code. Their attached test scripts useDELETEand must be adapted if this PR is merged.Suggestions on how to test this:
The attached script erase-post-test.sh tests this against the development containers. Run it with the API token of a superuser:
API_TOKEN=<token> ./erase-post-test.sh. It needscurlandjq. The exit code is 0 if the test passes, 1 if it fails and 2 if it is inconclusive, for example because the setup failed. Only use it on a disposable development instance: it publishes a dataset and erases its file. The dataset remains.By hand, with the setting mentioned above set to
false:curlcommands in the guide. The first returns a token and the second erases the file, after which its download returns 410.Content-Type: application/jsonfor another file. The response is 415.Does this PR introduce a user interface change? If mockups are available, please link/include them here:
No.
Is there a release notes update needed for this change?:
Not separately, as file erasure has not been released yet.
Additional documentation:
doc/sphinx-guides/source/admin/file-erasure.rsthas been updated.🤖 Generated with Claude Code