fix(ai-aliyun-content-moderation): return nil instead of ngx.OK in lua_body_filter#13623
Open
janiussyafiq wants to merge 1 commit into
Open
Conversation
nic-6443
approved these changes
Jun 29, 2026
membphis
approved these changes
Jun 29, 2026
membphis
left a comment
Member
There was a problem hiding this comment.
Code review looks good to me. Please make sure CI is green before merging.
shreemaan-abhishek
approved these changes
Jun 29, 2026
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
ai-aliyun-content-moderation'slua_body_filterreturnedngx.OKon the streamingfinal_packetpath. Inapisix/plugin.lua'slua_response_filter, returning a non-nil code prints the body andngx.exits the whole response filter chain, so any lower-priority response body filter is skipped.Because
ai-aliyun-content-moderation(priority 1029) runs beforeai-lakera-guard(priority 1028), a route chaining both terminated the chain beforeai-lakera-guard's output scan ran — even thoughfinal_packetonly annotatesrisk_leveland never blocks. The result was a silent moderation gap: a streamed response thatai-lakera-guardwould block could leak through unscanned.This returns
nil(transform-and-continue) instead ofngx.OKon thefinal_packetpath, so the chain keeps running lower-priority response body filters. The paths that genuinely terminate the response (realtimeblock) still return a code and are unchanged.A combined-plugin streaming test (
t/plugin/ai-lakera-guard-chain.t) is added: it assertsai-lakera-guard's output scan still runs and blocks a flagged stream when chained afterai-aliyun-content-moderation, and that a clean stream still passes through the chain.Which issue(s) this PR fixes:
Fixes #13620
Checklist