Skip to content

[dtq-dev-93] Fix 500/400 on share link, ePIC list, featured services, by-handle download and CMDI file links - #1774

Open
milanmajchrak wants to merge 5 commits into
dtq-dev-93from
93/be-error-responses
Open

milanmajchrak wants to merge 5 commits into
dtq-dev-93from
93/be-error-responses

Conversation

@milanmajchrak

@milanmajchrak milanmajchrak commented Nov 26, 2026 •

Copy link
Copy Markdown
Collaborator

References

No dtq-dev source. The same bugs are on dtq-dev; they are fixed on v9 only.

The FE branch 93/fe-share-link-mail-warning reads the new emailSent flag and shows a warning instead of "sent successfully".

Description

Five endpoints answered 500 or 400 where they should work or give a clear error. Now the share link is returned even when the e-mail fails (with emailSent: false), the ePIC list says it is not configured, the featured services list answers 405, an allowed user can download a non-public file by handle, and CMDI file links survive a quote in the file name.

Instructions for Reviewers

List of changes in this PR:

  • SubmissionController: when the share link e-mail cannot be sent, the error is logged and the link is still returned (was 500, although the token was already saved). The response has a new emailSent field. It is true only when the mail went out, and false when sending failed or mail is disabled (mail.server.disabled).
  • EpicHandleRestController: if lr.pid.service.url, lr.pid.service.user or lr.pid.service.pass is empty, every endpoint answers 404 with a message that names them. The admin page shows the message. Before, the call went out without credentials and ended as 500 "An exception has occurred".
  • ClarinFeaturedServiceRestRepository.findAll returned null, so /api/core/featuredservices (listed in the HAL root) gave 500. It now answers 405, like other repositories without a list. The item page does not use it; it reads /api/core/refbox/services, which works.
  • BitstreamByHandleRestController streamed the file through a new, anonymous Context, and retrieve() checked READ again on it. A logged-in user who may read a non-public file got 500 (403 in MockMvc). It now streams with the request context. Anonymous still gets 401, a user without rights 403.
  • lindat_cmdi.xsl: a proxy that rewrites the path (the /repository/ deployment) decodes it, so %22 reaches Tomcat as a bare quote and it answers 400. A cmd:ResourceRef now uses /api/core/bitstreams/handle/<handle>?filename=<name> only when the name has one of these characters: " % / ; < > [ \ ] ^ { | } and the backtick. They are the ones that fail behind such a proxy. The query string is passed as is. Links of all other files stay byte for byte the same.
  • One new IT per fix in SubmissionControllerIT, EpicHandleRestControllerIT, ClarinRefBoxControllerIT, BitstreamByHandleRestControllerIT and CmdiDownloadLinkIT. EpicHandleRestControllerIT now sets test credentials and resets the JVM-wide Authenticator after each test.

How to test:

  • mvn verify -pl dspace-server-webapp,dspace -am -DskipIntegrationTests=false -Dtest=none -DfailIfNoTests=false -Dsurefire.failIfNoSpecifiedTests=false -Dit.test=SubmissionControllerIT,EpicHandleRestControllerIT,ClarinRefBoxControllerIT,BitstreamByHandleRestControllerIT,CmdiDownloadLinkIT. All pass. Without the main-code changes the 5 new tests and the emailSent check in generateShareTokenAndSetOwnerTest fail. The ePIC test also checks that ePIC is never called.
  • Without SMTP, click Share submission in MyDSpace. The share page opens with the link and the response has emailSent: false.
  • Without ePIC credentials, open the ePIC handle admin page and enter a prefix. You see the "not configured" message, not "An exception has occurred".
  • Log in as a user who may read a non-public file and download it with /server/api/core/bitstreams/handle/<handle>?filename=<name>. You get the file.
  • Harvest an item with files a b.txt and a"b.txt with metadataPrefix=cmdi. The first keeps the path form, the second gets ?filename=. Both download behind /repository/, none gives 400.

Codex review (gpt-6.2-sol, high), 2 rounds: 2 findings fixed (emailSent was true with mail disabled, the ePIC test could reach the network). The last round found 2 more, not changed: a broken mail template still gives 500, and a config reload during a send can misreport emailSent.

Checklist

  • My PR is created against the main branch of code (unless it is a backport or is fixing an issue specific to an older branch).
  • My PR is small in size (e.g. less than 1,000 lines of code, not including comments & integration tests). Exceptions may be made if previously agreed upon.
  • My PR passes Checkstyle validation based on the Code Style Guide.
  • My PR includes Javadoc for all new (or modified) public methods and classes. It also includes Javadoc for large or complex private methods.
  • My PR passes all tests and includes new/updated Unit or Integration Tests based on the Code Testing Guide.
  • My PR includes details on how to test it. I've provided clear instructions to reviewers on how to successfully test this fix or feature.
  • If my PR includes new libraries/dependencies (in any pom.xml), I've made sure their licenses align with the DSpace BSD License based on the Licensing of Contributions documentation.
  • If my PR modifies REST API endpoints, I've opened a separate REST Contract PR related to this change.
  • If my PR includes new configurations, I've provided basic technical documentation in the PR itself.
  • If my PR fixes an issue ticket, I've linked them together.

🤖 Generated with Claude Code

milanmajchrak and others added 5 commits November 26, 2026 15:33
The token is already saved, so a mail failure is logged and the link is still returned.
The new emailSent flag tells the UI whether the mail went out.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Without lr.pid.service.url, user or pass, the ePIC endpoints answer 404 with a message
the admin page shows, and do not call ePIC.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
findAll returned null. Featured services come from the configuration per item.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The anonymous download context failed the second READ check, so a user allowed
to read a non-public file got 500.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A proxy that rewrites the path decodes it, and Tomcat refuses a bare quote and similar characters.
Only such names use ?filename=; all other links stay the same.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

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.

1 participant