fix: reevaluate logger meta filters during response phases#13727
Open
goutamadwant wants to merge 1 commit into
apache:masterapache/apisix:masterfrom
goutamadwant:fix/logger-meta-filter-phase-cachegoutamadwant/apisix:fix/logger-meta-filter-phase-cacheCopy head branch name to clipboard
Open
fix: reevaluate logger meta filters during response phases#13727goutamadwant wants to merge 1 commit intoapache:masterapache/apisix:masterfrom goutamadwant:fix/logger-meta-filter-phase-cachegoutamadwant/apisix:fix/logger-meta-filter-phase-cacheCopy head branch name to clipboard
goutamadwant wants to merge 1 commit into
apache:masterapache/apisix:masterfrom
goutamadwant:fix/logger-meta-filter-phase-cachegoutamadwant/apisix:fix/logger-meta-filter-phase-cacheCopy head branch name to clipboard
Conversation
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
Logger plugins run an access-phase handler to capture request bodies. This caused
_meta.filterexpressions that reference response variables to be evaluated before those variables were available, with the access-phase result reused during the log phase. Reading$statusduring access also cached0inctx.var, which could affect other plugins on the same request.This change:
_meta.filterresult caching to each execution phase, while retaining caching for repeated callbacks within the same phase$statusfrom being cached because its value changes after the response status is determinedWhich issue(s) this PR fixes:
Fixes #13724
Tests
prove -I. -r t/core/ctx2.tprove -I. -r t/plugin/file-logger3.tprove -I. -r t/plugin/plugin.tprove -I. -r t/plugin/file-logger.t t/plugin/file-logger2.t./utils/lj-releng apisix/plugin.lua apisix/core/ctx.luaThe issue scenarios were also reproduced on APISIX 3.17.0 and verified against the patched source. Gateway-generated 404 responses are filtered as configured, while upstream 200 and 404 responses are logged with their actual status values.
Checklist