Repository navigation
fix: invalidate req_post_args and post_arg.* cache on set_body_data - #14043
Open
bhuvan-somisetty wants to merge 1 commit into
Open
bhuvan-somisetty wants to merge 1 commit into
bhuvan-somisetty wants to merge 1 commit into
Conversation
In `apisix/patch.lua`, monkey-patched `ngx.req.set_body_data` only cleared `_request_body_table` and `_request_body_type`, leaving `api_ctx.req_post_args` with stale cached arguments from the pre-rewrite body. Additionally, clearing `post_arg.*` variables in `var._cache` was gated behind `api_ctx._request_body_table`, skipping variable invalidation if `_request_body_table` had not been populated or had already been cleared. This commit updates `ngx.req.set_body_data` to always invalidate `api_ctx.req_post_args` as well as any cached `post_arg.*` variables in `api_ctx.var._cache` regardless of `_request_body_table` status. Signed-off-by: bhuvan-somisetty <somisettybhuvan5@gmail.com>
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
In
apisix/patch.lua, monkey-patchedngx.req.set_body_dataonly cleared_request_body_tableand_request_body_type, leavingapi_ctx.req_post_argspopulated with stale cached form arguments from the pre-rewrite body. In addition, invalidation ofpost_arg.*variables invar._cachewas nested insideif api_ctx and api_ctx._request_body_table then, which skipped variable cache invalidation whenever_request_body_tablewas not yet populated or was nil.This PR updates
ngx.req.set_body_data:api_ctx.req_post_argsso that subsequent calls tocore.request.get_post_args(ctx)re-parse arguments from the updated body.post_arg.*variables inapi_ctx.var._cachewheneverngx.req.set_body_datais invoked.t/core/request.t(TEST 20).Which issue(s) this PR fixes:
Fixes #14042
Checklist