shreemaan-abhishek opened a new pull request, #13887:
URL: https://github.com/apache/apisix/pull/13887

   ### Description
   
   For the `passthrough` protocol, `ai-proxy` forwards the client's request 
method, path and query string verbatim (`ai-proxy/base.lua`), so on a wildcard 
route they select which upstream endpoint answers. The `ai-cache` fingerprint 
covered only the client body and the instance config, so the same body sent to 
`/v1/images/generations` and `/v1/chat/completions` (or to one path with 
different query parameters) collided on one cache entry and the second request 
was served the first one's response.
   
   This folds the client method, `uri` and `args` into `build_repr` under a 
passthrough gate. Other protocols build a fixed upstream request from the body 
alone, so their fingerprints are unchanged; an existing entry keeps its key.
   
   Tests: a `key.lua` unit block (path, query and method each flip the 
passthrough fingerprint; the `openai-chat` fingerprint still ignores the client 
path) plus an end-to-end sequence on a `/v1/*` route: same body to two upstream 
paths is MISS/MISS, a query-string variant is a MISS, and an exact repeat is a 
HIT. Without the fix TESTs 58, 61 and 62 fail.
   
   Docs: the `cache_key` note in `ai-cache.md` (en/zh) now states that 
passthrough keys include the method, path and query.
   
   #### Which issue(s) this PR fixes:
   <!--
   *Automatically closes linked issue when PR is merged.
   Usage: `Fixes #<issue number>`, or `Fixes (paste link of issue)`.
   -->
   Fixes #
   
   ### 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
   - [x] I have verified that this change is backward compatible (If not, 
please discuss on the [APISIX mailing 
list](https://github.com/apache/apisix/tree/master#community) first)


-- 
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