Skip to content

Return 400 Bad Request when request body converter returns incompatible type#2562

Open
BabalolaBrainiac wants to merge 1 commit into
spring-projects:mainfrom
BabalolaBrainiac:issue-1194-uri-list-400
Open

Return 400 Bad Request when request body converter returns incompatible type#2562
BabalolaBrainiac wants to merge 1 commit into
spring-projects:mainfrom
BabalolaBrainiac:issue-1194-uri-list-400

Conversation

@BabalolaBrainiac
Copy link
Copy Markdown

Fixes #1194.
|
When text/uri-list is posted to a non-association endpoint, UriListHttpMessageConverter returns a CollectionModel of links. The argument resolver then fails with an internal exception mapped to 500.
This change validates the converter output type and throws HttpMessageNotReadableException (400) instead.

  • Added type check in PersistentEntityResourceHandlerMethodArgumentResolver
  • Added unit test rejectsRequestBodyIfConverterReturnsIncompatibleType

  • You have read the Spring Data contribution guidelines.
  • You use the code formatters provided here and have them applied to your changes. Don't submit any formatting related changes.
  • You submit test cases (unit or integration tests) that back your changes.
  • You added yourself as author in the headers of the classes you touched. Amend the date range in the Apache license header if needed. For new types, add the license header (copy from another file and set the current year only).

@BabalolaBrainiac BabalolaBrainiac force-pushed the issue-1194-uri-list-400 branch from 8cd6da9 to a6390d9 Compare May 17, 2026 20:18
…le type.

When text/uri-list is posted to a non-association endpoint,
UriListHttpMessageConverter returns a CollectionModel instead of the
target domain type. The argument resolver then fails with an internal
exception mapped to 500.

This change validates the converter output type and throws
HttpMessageNotReadableException (400) instead.

Fixes spring-projects#1194

Signed-off-by: Babalola Opeyemi Daniel <babalolaopedaniel@gmail.com>
@BabalolaBrainiac BabalolaBrainiac force-pushed the issue-1194-uri-list-400 branch from a6390d9 to 8c56fec Compare May 17, 2026 20:19
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label May 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: waiting-for-triage An issue we've not yet triaged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Posting text/uri-list to the wrong location results in a 500 [DATAREST-818]

2 participants