Skip to content

Get Serialized Names in Exception Handler #26508

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

Closed
dirweis opened this issue Feb 4, 2021 · 5 comments
Closed

Get Serialized Names in Exception Handler #26508

dirweis opened this issue Feb 4, 2021 · 5 comments
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket)

Comments

@dirweis
Copy link

dirweis commented Feb 4, 2021

In the ExceptionHandler for MethodArgumentNotValidExceptions a way for getting the serialized names of the violated fields is missing. Using MethodArgumentNotValidException.getBindingResult().getAllErrors() ... FieldError.getField() the POJO's name is returned which is not acceptable for the response body in case of different serialized names (Example: photoUrls vs. photo-urls).

Code:

@JsonProperty("photo-urls")
private List<URL> photoUrls;

In this case photoUrls is returned which is the wrong key for the client's request.

@wilkinsona
Copy link
Member

Thanks for the suggestion. As with https://github.com/spring-projects/spring-boot/issues/25104, this issue really belongs in Spring Framework. We'll transfer the issue over to them. You can identify enhancements that belong in the Spring Boot project by their code's package. All Spring Boot code is in an org.springframework.boot package or sub-package.

@bclozel bclozel transferred this issue from spring-projects/spring-boot Feb 4, 2021
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Feb 4, 2021
@bclozel
Copy link
Member

bclozel commented Feb 4, 2021

See #26507

@rstoyanchev rstoyanchev added the in: web Issues in web modules (web, webmvc, webflux, websocket) label Nov 10, 2021
@snicoll
Copy link
Member

snicoll commented Nov 29, 2023

I am not sure I get the link with @JsonProperty. This is a Jackson-specific hint and the validation happens on the POJO, not on the content of the JSON object. Besides FieldError is pretty specific.

This seems to me that these are two layers of responsibility that should be separate. Thoughts?

@snicoll snicoll added the status: waiting-for-feedback We need additional information before we can continue label Nov 29, 2023
@spring-projects-issues
Copy link
Collaborator

If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.

@spring-projects-issues spring-projects-issues added the status: feedback-reminder We've sent a reminder that we need additional information before we can continue label Dec 6, 2023
@spring-projects-issues
Copy link
Collaborator

Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.

@spring-projects-issues spring-projects-issues closed this as not planned Won't fix, can't repro, duplicate, stale Dec 13, 2023
@spring-projects-issues spring-projects-issues removed status: waiting-for-feedback We need additional information before we can continue status: feedback-reminder We've sent a reminder that we need additional information before we can continue status: waiting-for-triage An issue we've not yet triaged or decided on labels Dec 13, 2023
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)
Projects
None yet
Development

No branches or pull requests

6 participants