AlinsRan opened a new pull request, #13546:
URL: https://github.com/apache/apisix/pull/13546
### What this fixes
The ai-proxy **passthrough** protocol is a catch-all that proxies the
original client request to the provider. But the upstream request builder in
`apisix/plugins/ai-providers/base.lua` drops two parts of the client request:
```lua
local query_params = auth.query and core.table.clone(auth.query) or {}
-- ... only auth.query and the override.endpoint URL query are merged;
-- the client's own query string (ctx.var.args) is never added ...
local params = {
method = "POST", -- hardcoded
...
query = query_params,
}
```
So for passthrough:
- the **client query string is dropped** — this breaks providers that
require parameters in the query on POST requests, e.g. **Azure OpenAI's
`?api-version=...`**;
- the **method is always POST**, so a non-POST client request (carrying a
JSON body) is not forwarded with its original method.
### Change
For the passthrough protocol (`ctx.ai_target_protocol == "passthrough"`),
forward the client's HTTP method (`core.request.get_method()`) and merge the
client's query string (`ctx.var.args`) into the upstream request. Other
protocols are unchanged (still POST with provider-specific query args).
### Test
Adds two cases to `t/plugin/ai-proxy-passthrough.t`: a passthrough request
with `?name=foo` asserts the arg reaches the upstream, and a `PUT` passthrough
request asserts the upstream sees `PUT`.
> Note: I could not run the ai-proxy test harness locally — please rely on
CI to validate the new tests.
### 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 (N/A)
- [x] I have verified that the changes pass the existing tests
--
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]