janiussyafiq opened a new pull request, #13623:
URL: https://github.com/apache/apisix/pull/13623

   ### Description
   
   `ai-aliyun-content-moderation`'s `lua_body_filter` returned `ngx.OK` on the 
streaming `final_packet` path. In `apisix/plugin.lua`'s `lua_response_filter`, 
returning a non-nil code prints the body and `ngx.exit`s the whole response 
filter chain, so any lower-priority response body filter is skipped.
   
   Because `ai-aliyun-content-moderation` (priority 1029) runs before 
`ai-lakera-guard` (priority 1028), a route chaining both terminated the chain 
before `ai-lakera-guard`'s output scan ran — even though `final_packet` only 
annotates `risk_level` and never blocks. The result was a silent moderation 
gap: a streamed response that `ai-lakera-guard` would block could leak through 
unscanned.
   
   This returns `nil` (transform-and-continue) instead of `ngx.OK` on the 
`final_packet` path, so the chain keeps running lower-priority response body 
filters. The paths that genuinely terminate the response (`realtime` block) 
still return a code and are unchanged.
   
   A combined-plugin streaming test (`t/plugin/ai-lakera-guard-chain.t`) is 
added: it asserts `ai-lakera-guard`'s output scan still runs and blocks a 
flagged stream when chained after `ai-aliyun-content-moderation`, and that a 
clean stream still passes through the chain.
   
   #### Which issue(s) this PR fixes:
   Fixes #13620
   
   ### Checklist
   
   - [x] I have explained the need for this PR and the problem it solves
   - [x] I have explained the changes or the new features added to this PR
   - [x] I have added tests corresponding to this change
   - [ ] I have updated the documentation to reflect this change
   - [x] I have verified that this change is backward compatible
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to