-
Notifications
You must be signed in to change notification settings - Fork 41.2k
HATEOAS: ResponseEntity<Resource> from @ExceptionHandler method not converted to HAL #8174
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
Comments
I'm not sure this is supported by Spring HATOAS in the first, nor that representing an exception instance as a HAL resource makes sense. As far as I know, Boot does nothing special in that area. Could you open this issue against the original project? (actually, is this a duplicate?) |
@mvitz I second that, please consider creating an issue in the original project first unless you have a strong indication that this is auto-configuration related. |
@snicoll for me (and I would consider myself as an advanced spring user) it's not always obvious which component is responsible for such stuff. As a user I would expect that if I use the HATEOAS auto configuration and HAL is working from controller methods it works in an exception handler method as well. I never expected that this issue would be outside of configuration. Using HATEOAS without Boot requires me to Annotate some Configuration with @blcozel I'm sorry if I cause additional work for this team but I think you should see this as a positive thing. I'm trying to help and improve your work and do not stop using it silently. Additionally I would like to thank you for all the good work. |
We obviously see your (and any report in genral) as a positive thing. But it isn't obvious from your report that this is working without Spring Boot. Actually you've done all that work but you didn't mention it! |
Do you mean that you got this very use case to work when using the |
Yes. If I add @EnableHypermedia this use case works. After some digging it this works because with the annotation the main Jackson object mapper is changed. With only the autoconfiguration present an additional mapper is created. |
I've reproduced the problem, and also reproduced it working when adding |
When you use If you don't use It doesn't work for the error response in the sample as the /cc @olivergierke |
There's no easy way that I can see for us to create or lay our hands on a @olivergierke Can you please take a look at this? |
Thanks for all your work up to this point. |
I think we're gonna have to investigate how to register the Spring HATEOAS is on Spring 4.3 in the meantime and quite a few new MVC customization APIs have been introduced since we started that rather convoluted implementation. I think we might be able to get away with something dramatically simpler and less error prone. It might also mean that a bit of the setup in Spring Data REST has to be revisited as part of that slightly weird design (inspecting existing beans and leniently registering |
@olivergierke where is this going to be implemented. I am asking this issue is flagged for 1.4.x atm. |
It looks like we can't fix this without a Spring HATEOAS change. I'm going to close this one for now. If we get an update in Spring HATEOAS we'll reconsider. |
We've just pushed some significant configuration changes to Spring HATEOAS (both on master as well on the bugfix branch for the upcoming 0.25.0) in the context of spring-projects/spring-hateoas#719 and spring-projects/spring-hateoas#723. I've adapted Spring Data REST to work with these changes (coming in Lovelace) and verified our Spring Data examples work with these changes on Boot 2.0.3. Find the details of what has changed in the tickets I linked above. I'd like to encourage everyone who brought up issues in this ticket to try to upgrade to Spring HATEOAS 0.25.0.BUILD-SNAPSHOT (it doesn't contain any major changes but the ones just described), give it a spin and report problems you (still see) in spring-projects/spring-hateoas#719. |
Thanks, when upgrading the example to Spring Boot 2.0.3 and Hateoas 0.25.0.BUILD-SNAPSHOT everything works as expected. |
Thanks for confirming, Michael! 👍 |
Given a controller like https://github.com/mvitz/spring-boot-hateoas-autoconfiguration-bug/blob/master/src/main/java/de/mvitz/spring/hateoas/server/ExceptionController.java with a
@ExceptionHandler
annotated method the response is not converted to valid HAL, see:Maybe I am (again) missing some little thing here but I think given the example controller I should expect to receive a response with valid HAL.
Issue occurs with Spring-Boot 1.4.4.RELEASE and 1.5.1.RELEASE as well.
The text was updated successfully, but these errors were encountered: