-
-
Notifications
You must be signed in to change notification settings - Fork 376
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
Regression: Response serializer no longer replaces response #657
Comments
How did you get 7 |
I see the regression, v1.x const result = s.serializer(handler.response)
if (typeof result === 'object') {
// replace response object if result is object
handler.response = result
} else {
// otherwise only replace the body attribute
handler.response.body = result
} v2.x request.response.body = s.serializer(request.response) I do recall simplifying because any object doesn't mean it will be an acceptable response for http. How about this: const result = s.serializer(handler.response)
if (result?.body) {
handler.response = result
} else {
// otherwise only replace the body attribute
handler.response.body = result
} This should give you the flexibility you need while ensuring the correct response structure is maintained. Let me know if this works for you, I can add it in. |
@willfarrell that will work just as well I think, thank you. |
Will be in the next release. v2.1.0 |
It would be great if this is released soon because it's currently breaking our flow. Thanks! |
It will likely be released this week. I'm just waiting on feedback for a new middleware. |
Thanks for the prompt release @willfarrell. |
Or perhaps - check if |
OK so it's worse than that @willfarrell - if one has I think we would have to check for |
v2.1.1 is on it's way |
What are the steps to reproduce this issue?
Create a serializer that returns an object.
What happens?
The serializer returned object is set on the body.
What were you expecting to happen?
The returned object should replace the entire response object as the documentation states:
(and as it was in v1)
Any other comments?
Seems to me like the behavior had changed since this change
I think the only reason the pre-existing unit test did not break was because the response object itself was mutated.
What versions of software are you using?
Node.js Version: 14
Middy Version: 2.0.1
The text was updated successfully, but these errors were encountered: