shreemaan-abhishek opened a new pull request, #13605:
URL: https://github.com/apache/apisix/pull/13605
### Description
`apisix/utils/log-sanitize.lua`'s `redact_params` / `redact_extra_opts`
already return a recycled `delay_encode` pool slot (a `{data=, force=}` table
with a `__tostring` metamethod). The AI plugin call sites then wrap that slot
in `core.json.delay_encode(..., true)` a second time:
- `apisix/plugins/ai-proxy/base.lua:265`
- `apisix/plugins/ai-providers/base.lua:132`
- `apisix/plugins/ai-providers/base.lua:779`
When the log line flushes, cjson encodes the inner wrapper **table** (cjson
ignores `__tostring`), so the log emits the wrapper structure instead of the
redacted JSON. Worse, `delay_encode` recycles a 16-slot pool, so by flush time
the inner slot may already hold an unrelated request's data, risking stale or
unredacted content from a different request in the logs. This triggers on every
AI-proxy / ai-providers request log at info level.
This makes the sanitizer return raw tables and lets the single
`delay_encode` already present at each call site do the encoding.
### 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
- [x] I have updated the documentation to reflect this change (no public
behavior/docs change)
- [x] I have verified that this change is backward compatible (the log
content is now correct; no API change)
--
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]