Skip to content

File erase post instead of delete - #12939

Draft
janvanmansum wants to merge 17 commits into
IQSS:developfrom
janvanmansum:FileErase-post-instead-of-delete
Draft

janvanmansum wants to merge 17 commits into
IQSS:developfrom
janvanmansum:FileErase-post-instead-of-delete

Conversation

@janvanmansum

@janvanmansum janvanmansum commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

What this PR does / why we need it:

DELETE /api/files/{id}/erase requires a JSON body. In a freshly created development container, Payara answered every DELETE request with a body with an empty 400 response, before it reached Dataverse. The setting server.network-config.protocols.protocol.http-listener-1.http.allow-payload-for-undefined-http-methods was false there. After it was set to true, 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 DELETE request and advises against relying on it (RFC 9110, section 9.3.5):

Although request message framing is independent of the method used, content received in a DELETE request has no generally defined semantics, cannot alter the meaning or target of the request, and might lead some implementations to reject the request and close the connection because of its potential as a request smuggling attack (Section 11.2 of [HTTP/1.1]). A client SHOULD NOT generate content in a DELETE request unless it is made directly to an origin server that has previously indicated, in or out of band, that such a request has a purpose and will be adequately supported. An origin server SHOULD NOT rely on private agreements to receive content, since participants in HTTP communication are often unaware of intermediaries along the request chain.

So even if Payara accepts the body, a proxy or load balancer in front of it may reject or change the request. See also:

  • MDN: DELETE requests "shouldn't contain a body".
  • OpenAPI 3.1.0: for methods such as 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 on FileErase has no request body for this endpoint.
  • Grizzly, the HTTP server used by Payara, lists GET, HEAD and DELETE as methods for which the specification does not clearly state whether they support a payload.

POST fits, as the server processes the body. The file resource also remains: the content is erased, but the DataFile is kept and a FileErasure is added.

Which issue(s) this PR closes:

None. This is a change to the FileErase branch.

Special notes for your reviewer:

  • This changes the API: DELETE is no longer supported for this path. The branch has not been merged, so there is no released API to keep compatible.
  • The endpoint now requires Content-Type: application/json. The commands in the guide did not set it, so curl -d sent the form type. For a POST request the servlet container may parse such a body as form parameters. With @Consumes, a wrong type is rejected clearly.
  • I did not use query parameters on DELETE, because the reason (which may contain GDPR details) and the token would end up in access logs.
  • The PRs for FileErase-delete-after-commit and FileErase-bind-confirmation-token change nearby code. Their attached test scripts use DELETE and 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 needs curl and jq. 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:

  1. Publish a dataset with a file.
  2. Use the two curl commands in the guide. The first returns a token and the second erases the file, after which its download returns 410.
  3. Repeat the first command without Content-Type: application/json for 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.rst has been updated.

🤖 Generated with Claude Code

This branch has not been deployed

No deployments
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 this pull request may close these issues.

2 participants