-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
fix(response-transformer): fix the error when response-transformer #9463
fix(response-transformer): fix the error when response-transformer #9463
Conversation
It seems to be duplicated with PR #9491, could you take a look at it? |
@chronolaw I've checked PR 9491, it has a similar logic with this, except that in #9491, when transforming a non-json body, it will throw a warn-level log indicating the failure, while this one won't. |
Great. Could you talk to @samugi and integrate these two PRs? |
if json_body == nil then | ||
return | ||
return nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return nil | |
return nil, "failed parsing json body" |
I think it would be useful to return a warning, then log it in case of parsing failure
Thank you @chronolaw for spotting the duplicate. I think adding the warning would be useful, then we can close mine. |
spec/03-plugins/15-response-transformer/02-body_transformer_spec.lua
Outdated
Show resolved
Hide resolved
spec/03-plugins/15-response-transformer/02-body_transformer_spec.lua
Outdated
Show resolved
Hide resolved
28e8bdf
to
498278d
Compare
498278d
to
aa2e1e3
Compare
spec/03-plugins/15-response-transformer/02-body_transformer_spec.lua
Outdated
Show resolved
Hide resolved
I think it would be a good idea to cover the behaviour of |
850562e
to
e93bf9e
Compare
@liverpool8056 could you add this too? ^ |
@samugi It seems that I've already added a similar test. |
@liverpool8056 The current unit test covers the |
e93bf9e
to
5787c05
Compare
plugin breaks when receiving an unexcepted body.
5787c05
to
3fcddb6
Compare
@samugi understood, thanks! |
Summary
Fix the error that the response from upstream is a plain string with Header Content-Type: application/json, the response transformer throw exception when transforming.