Repository navigation
fix: invalidate req_post_args and post_arg.* cache on set_body_data - #14043
bhuvan-somisetty wants to merge 2 commits 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>
|
Thanks for the PR, @bhuvan-somisetty! Could we also invalidate the legacy After reading Please cover both prefixes and add a regression case that reads |
Extend the var._cache invalidation loop in patched ngx.req.set_body_data to also match the legacy "post_arg_" prefix, preventing stale post_arg_foo variables after a request body rewrite. Also update TEST 20 in t/core/request.t to verify post_arg_ cache invalidation. Signed-off-by: bhuvan-somisetty <somisettybhuvan5@gmail.com>
|
Good point! I've updated the invalidation logic in |
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