Skip to content

Issue 1228: return error 400 rather than error 500 on anonymous user file download#1379

Open
kuchtiak-ufal wants to merge 9 commits into
clarin-v7from
issue_#1228_fixed_exception_when_anonymous_user_is_downloading_file
Open

Issue 1228: return error 400 rather than error 500 on anonymous user file download#1379
kuchtiak-ufal wants to merge 9 commits into
clarin-v7from
issue_#1228_fixed_exception_when_anonymous_user_is_downloading_file

Conversation

@kuchtiak-ufal

@kuchtiak-ufal kuchtiak-ufal commented Jun 30, 2026

Copy link
Copy Markdown

Resolving multiple problems with file-download, that requires License agreement:

  • check whether manageUserMetadata payload contains all required metadata keys. Return error 400 otherwise
  • handle empty payload in manageUserMetadata POST request - return 400 rather than Server error (500)
    (this issue is described here: Clarin Licenses: Server error when anonymous user is downloading file #1228)
  • filter the payload and store only metadata keys related to Clarin license (ignore other fields from the payload)
  • handle specially the "required" metadata keys that are optional, e.g. ORGANIZATION(optional)

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR addresses Issue 1228 by ensuring requests to the CLARIN user-metadata “manage” endpoint return HTTP 400 (Bad Request) instead of HTTP 500 when an anonymous user submits an empty/invalid JSON body, and adds an integration test to verify that behavior.

Changes:

  • Inject and reuse a Spring-managed ObjectMapper in ClarinUserMetadataRestController.
  • Convert Jackson mapping errors in the bitstream “manage” endpoint into DSpaceBadRequestException (400).
  • Add an IT case asserting that an empty request body returns 400 for anonymous access when anonymous downloads are allowed.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
dspace-server-webapp/src/main/java/org/dspace/app/rest/repository/ClarinUserMetadataRestController.java Adds ObjectMapper injection and maps certain JSON-body errors to 400 for the bitstream manage endpoint.
dspace-server-webapp/src/test/java/org/dspace/app/rest/ClarinUserMetadataRestControllerIT.java Adds integration test coverage for empty JSON body returning 400.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

@kuchtiak-ufal
kuchtiak-ufal requested a review from kosarko June 30, 2026 10:00

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

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.

Clarin Licenses: Server error when anonymous user is downloading file

2 participants