Copilot commented on code in PR #13449:
URL: https://github.com/apache/apisix/pull/13449#discussion_r3317484983


##########
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:
   `simdjson_decode` logs a warning before attempting the `cjson` retry, which 
means *any* simdjson decode failure (including fully invalid JSON where `cjson` 
will also fail) will emit a warning and do two decode attempts. Consider only 
logging when the `cjson` fallback succeeds (simdjson failed but cjson decoded), 
and if the fallback also fails, return the original simdjson error (or the 
cjson error) without logging to avoid log noise on client errors and 
unnecessary work.
   



-- 
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]

Reply via email to