fix: fallback to cjson after simdjson decode errors#13449
Open
nic-6443 wants to merge 2 commits into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
This PR improves robustness of JSON request-body decoding when apisix.request_body_json_lib is set to simdjson by retrying with cjson after simdjson decode failures, aiming to keep simdjson as the fast path while preserving previous cjson compatibility.
Changes:
- Add a simdjson→cjson fallback path in
apisix.core.request_json.decode()with a warning log on simdjson decode failures. - Update
api7-lua-resty-simdjsondependency to0.1.2-1. - Add/adjust tests and update ai-proxy documentation (EN/ZH) to reflect the fallback behavior.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
apisix/core/request_json.lua |
Adds simdjson decode wrapper that logs and falls back to cjson decoding on failure. |
apisix-master-0.rockspec |
Bumps api7-lua-resty-simdjson version to include decoder cleanup after errors. |
t/core/request.t |
Adds a regression test ensuring fallback to cjson occurs and warning is logged; renumbers subsequent tests. |
docs/en/latest/plugins/ai-proxy.md |
Documents warning + retry-with-cjson behavior for simdjson mode. |
docs/zh/latest/plugins/ai-proxy.md |
Same documentation update in Chinese. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
When
apisix.request_body_json_libis set tosimdjson, request body decoding now logs a warning and retries withcjsonifsimdjsonreturns a decode error. This keepssimdjsonas the default fast path while preserving the existingcjsonbehavior as a fallback path.This also updates
api7-lua-resty-simdjsonto0.1.2-1, which includes decoder state cleanup after errors.Checklist
Tests
TEST_NGINX_CASE=19 prove -Itest-nginx/lib -I. -r t/core/request.tprove -Itest-nginx/lib -I. -r t/core/request.tprove -Itest-nginx/lib -I. -r t/plugin/ai-proxy-simdjson-error-state.t