Skip to content
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

Using getBody and sending a JSON payload with null values causes error #8610

Closed
akira28 opened this issue Mar 2, 2022 · 2 comments · Fixed by #8611
Closed

Using getBody and sending a JSON payload with null values causes error #8610

akira28 opened this issue Mar 2, 2022 · 2 comments · Fixed by #8611
Labels

Comments

@akira28
Copy link

akira28 commented Mar 2, 2022

When using kong.request.getBody and sending a JSON payload including a null value, like

{ "key": null }

causes an error

2022/03/02 10:26:20 [error] 134#0: *3236 [kong] init.lua:297 [smart-logic] /usr/local/share/lua/5.1/MessagePack.lua:65: pack 'userdata' is unimplemented"

As a workaround I had to use the kong.request.getRawBody() and JSON.parse, but it's not the ideal solution.

Kong version: 2.7.1
Kong JS PDK version: 0.4.4 (I cannot upgrade to the latest one because of this: Kong/kong-js-pdk#151 )

@fffonion fffonion added the bug label Mar 9, 2022
@fffonion
Copy link
Contributor

fffonion commented Mar 9, 2022

@akira28 Could you open an issue at kong for visibility?

@StarlightIbuki
Copy link
Contributor

This bug is due to cjson's handling of null. It represents null as a nullptr(of type userdata, called NULL) and msgpack apparently doesn't know how to encode it.

@StarlightIbuki StarlightIbuki transferred this issue from Kong/kong-js-pdk Mar 30, 2022
StarlightIbuki added a commit that referenced this issue Mar 30, 2022
RPC(msgpack) did not recongnize cjson.null(userdata NULL).
Patch to make it compatible with cjson.

fix #8610
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants