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

Include argument name in MethodArgumentTypeMismatchException error message #33573

Open
vpavic opened this issue Sep 20, 2024 · 0 comments
Open
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) status: waiting-for-triage An issue we've not yet triaged or decided on

Comments

@vpavic
Copy link
Contributor

vpavic commented Sep 20, 2024

Using the latest release (6.1.13), when MethodArgumentTypeMismatchException happens, something like this is logged at warn level:

Resolved [org.springframework.web.method.annotation.MethodArgumentTypeMismatchException: Failed to convert value of type 'java.lang.String' to required type 'java.time.OffsetDateTime'; Failed to convert from type [java.lang.String] to type [@org.springframework.web.bind.annotation.RequestParam @org.springframework.format.annotation.DateTimeFormat java.time.OffsetDateTime] for value [2024-09-09T8:30:00+02:00]]

It would be very useful to also log the name of the argument which caused the error, because sometimes there are multiple handler method arguments of the same type that are subject to the same conversion. I guess this means that error message should be put together in MethodArgumentTypeMismatchException rather than relying on TypeMismatchException (which does not have the necessary context).

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Sep 20, 2024
@jhoeller jhoeller added the in: web Issues in web modules (web, webmvc, webflux, websocket) label Sep 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) status: waiting-for-triage An issue we've not yet triaged or decided on
Projects
None yet
Development

No branches or pull requests

3 participants