Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

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#13727
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

@goutamadwant

Copy link
Copy Markdown

Description

Logger plugins run an access-phase handler to capture request bodies. This caused _meta.filter expressions that reference response variables to be evaluated before those variables were available, with the access-phase result reused during the log phase. Reading $status during access also cached 0 in ctx.var, which could affect other plugins on the same request.

This change:

  • scopes _meta.filter result caching to each execution phase, while retaining caching for repeated callbacks within the same phase
  • prevents $status from being cached because its value changes after the response status is determined
  • adds regression coverage for response-phase filters and cross-plugin status isolation

Which issue(s) this PR fixes:

Fixes #13724

Tests

  • prove -I. -r t/core/ctx2.t
  • prove -I. -r t/plugin/file-logger3.t
  • prove -I. -r t/plugin/plugin.t
  • prove -I. -r t/plugin/file-logger.t t/plugin/file-logger2.t
  • ./utils/lj-releng apisix/plugin.lua apisix/core/ctx.lua

The 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

  • I have explained the need for this PR and the problem it solves
  • I have explained the changes or the new features added to this PR
  • I have added tests corresponding to this change
  • I have updated the documentation to reflect this change (Not applicable: this restores existing behavior without changing configuration or public APIs.)
  • I have verified that this change is backward compatible (If not, please discuss on the APISIX mailing list first)

@dosubot dosubot Bot added size:L This PR changes 100-499 lines, ignoring generated files. bug Something isn't working labels Jul 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: logger _meta.filter evaluates response-phase variables at access phase, breaking filters and caching $status as 0

1 participant

Morty Proxy This is a proxified and sanitized view of the page, visit original site.