Copilot commented on code in PR #13407:
URL: https://github.com/apache/apisix/pull/13407#discussion_r3279056586
##########
apisix/core/request_json.lua:
##########
@@ -28,6 +28,35 @@ local configured_name
local _M = {}
+local function qjson_decode(str)
+ local ok, decoded, err = pcall(qjson.decode, str)
+ if not ok then
+ return nil, tostring(decoded)
+ end
+
+ if not decoded then
+ return nil, err
+ end
+
+ ok, decoded = pcall(qjson.materialize, decoded)
+ if not ok then
+ return nil, tostring(decoded)
+ end
+
Review Comment:
`qjson_decode` wraps `qjson.materialize` with `pcall`, but it only captures
the first return value. If `qjson.materialize` returns `nil, err` (non-throwing
failure), this currently returns `nil` with a missing/empty error message,
regressing the previous `return qjson.materialize(decoded)` behavior. Capture
the second return value from `pcall(...)` and propagate it when `decoded` is
falsy (similar to how `qjson.decode` is handled).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]