Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(rest-api) improve error handling for 415 unsupported media type #30828 #30910

Conversation

valentinogiardino
Copy link
Contributor

@valentinogiardino valentinogiardino commented Dec 10, 2024

Proposed Changes

  • Added NotSupportedExceptionMapper to handle javax.ws.rs.NotSupportedException and return JSON responses for 415 Unsupported Media Type errors.
  • Included new test cases in the Postman collection to validate proper handling and responses for requests with invalid Content-Type headers.

Checklist

  • Tests
  • Translations
  • Security Implications Contemplated (add notes if applicable)

Additional Info

This PR addresses the issue where REST endpoints annotated with @Consumes(multipart/form-data) would return HTML responses instead of JSON when the Content-Type header is incorrect. The new implementation ensures consistency and better user experience by providing meaningful JSON error messages across the application.

Screenshots

Original Updated
image image

This PR fixes: #30828

@fabrizzio-dotCMS fabrizzio-dotCMS added this pull request to the merge queue Dec 10, 2024
Merged via the queue into main with commit d67b5fd Dec 10, 2024
36 checks passed
@fabrizzio-dotCMS fabrizzio-dotCMS deleted the issue-30828-rest-api-improve-error-handling-for-415-unsupported-media-type branch December 10, 2024 23:18
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.

Rest API: Improve error handling for 415 – Unsupported Media Type
3 participants