Skip to content

fix(ai-proxy): forward client method and query string for passthrough#13546

Open
AlinsRan wants to merge 1 commit into
apache:masterfrom
AlinsRan:fix/ai-proxy-passthrough-method-query
Open

fix(ai-proxy): forward client method and query string for passthrough#13546
AlinsRan wants to merge 1 commit into
apache:masterfrom
AlinsRan:fix/ai-proxy-passthrough-method-query

Conversation

@AlinsRan

@AlinsRan AlinsRan commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

TL;DR

The ai-proxy passthrough protocol dropped the client's query string and forced the method to POST, breaking providers that need query params on POST — e.g. Azure OpenAI's ?api-version=....

Cause

In apisix/plugins/ai-providers/base.lua, the upstream request builder hardcodes method = "POST" and merges only auth.query + the override.endpoint URL query — the client's own query string (ctx.var.args) is never added.

Fix

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

t/plugin/ai-proxy-passthrough.t: a passthrough request with ?name=foo asserts the arg reaches the upstream; 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

  • 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 (N/A)
  • I have verified that the changes pass the existing tests

@dosubot dosubot Bot added size:L This PR changes 100-499 lines, ignoring generated files. bug Something isn't working labels Jun 12, 2026
The passthrough protocol is a catch-all that proxies the original client
request to the provider, but the upstream request builder hardcoded the
method to POST and built the query string only from auth.query and the
override.endpoint URL — the client's own query string (ctx.var.args) was
dropped. This breaks providers that carry required parameters in the query
on POST requests, e.g. Azure OpenAI's ?api-version=. For the passthrough
protocol, forward the client's HTTP method and merge its query string into
the upstream request.

Signed-off-by: AlinsRan <alinsran@apache.org>
@AlinsRan AlinsRan force-pushed the fix/ai-proxy-passthrough-method-query branch from f5a6ae7 to f4e3899 Compare June 12, 2026 08:42
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.

1 participant