Issue-1438: Fix upstream service error represented as 400
Issue -https://github.com/disneystreaming/smithy4s/issues/1438
Issue description:
When an upstream service fails with a non-parseable response (e.g., due to an internal server error), the Smithy4s client wraps this failure in an HttpPayloadError. Currently, the Smithy4s server interprets this HttpPayloadError as a client-side error and responds with a 400 BadRequest. This behaviour incorrectly suggests that the error originated from the client's request, making it difficult to debug actual upstream service failures. The correct behaviour should be for the server to respond with a 500 InternalServerError, indicating an issue with the upstream service rather than the client's request.
Solution:
Define a new error type RawErrorResponse:
Created a new error type RawErrorResponse to represent detailed errors, including a failed decode attempt, originating from upstream services.
Update HttpResponse:
Updated HttpResponse to handle RawErrorResponse by including detailed information about the failed decode attempt when appropriate.
Test
Added a test case to PizzaSpec to validate the server's response when a RawErrorResponse is raised, ensuring that it returns a 500 status code with detailed information about the failed decode attempt.
- [x] Added unit-tests (for runtime code)
- [ ] Added bootstrapped code + smoke tests (when the rendering logic is modified)
- [ ] Added build-plugins integration tests (when reflection loading is required at codegen-time)
- [ ] Added alloy compliance tests (when simpleRestJson protocol behaviour is expanded/updated)
- [ ] Updated dynamic module to match generated-code behaviour
- [ ] Added documentation
- [ ] Updated changelog
@GaryAghedo for these errors:
There are files without headers!
You should be able to generate the missing headers with sbt headerCreateAll.
Hey @Baccata. PR ready to be reviewed thanks
I think it's shaping up well, but there's still a couple things to take care of though. Good work though !