Skip to content

Commit

Permalink
fix(server): serialize error and disable strict_map_key to allow (#117)
Browse files Browse the repository at this point in the history
uri_captures to be unpacked
  • Loading branch information
fffonion committed Jun 20, 2023
1 parent 3d6a349 commit 25db61c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion kong_pdk/listener.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def handle(self, fd, address, *_):
# can't use socket.makefile here, since it returns a blocking IO
# msgpack.Unpacker only expects read() but no other semantics to exist
sockf = WrapSocket(fd)
unpacker = msgpack.Unpacker(sockf)
unpacker = msgpack.Unpacker(sockf, strict_map_key=False)

for _, msgid, method, args in unpacker:
ns, cmd = method.split(".")
Expand Down
7 changes: 7 additions & 0 deletions kong_pdk/pdk/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@ def __getattr__(self, k):

def rpc_of(ch, lua_style):
def f(m, *a):
# sanitize non-serializable objects
if m == "kong.log" or m.startswith("kong.log."):
a = list(a)
for i in range(len(a)):
if type(a[i]) not in (str, int, list, dict):
a[i] = str(a[i])

ch.put({
"Method": m,
"Args": a,
Expand Down

0 comments on commit 25db61c

Please sign in to comment.