nic-6443 commented on code in PR #13449:
URL: https://github.com/apache/apisix/pull/13449#discussion_r3317489653
##########
apisix/core/request_json.lua:
##########
@@ -63,6 +64,18 @@ local function qjson_encode(data)
end
+local function simdjson_decode(str)
+ local decoded, err = simdjson_parser:decode(str)
+ if decoded ~= nil then
+ return decoded
+ end
+
+ log.warn("failed to decode request body with simdjson: ", err,
+ ", falling back to cjson")
+ return core_json.decode(str)
Review Comment:
I think we should keep the warning at the simdjson failure point here. The
fallback is meant to make `cjson` a compatibility retry path, but the signal we
need in logs is that simdjson failed for this body. If `cjson` also fails,
returning the cjson error is still useful because that is the final decoder
result seen by callers, while the warning preserves the original simdjson
failure context. The extra decode attempt is intentional when
`request_body_json_lib` is set to `simdjson`.
--
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]