fix(ai-cache): key the passthrough protocol on the client method, path and query - #13887
Open
shreemaan-abhishek wants to merge 2 commits into
Open
fix(ai-cache): key the passthrough protocol on the client method, path and query#13887shreemaan-abhishek wants to merge 2 commits into
shreemaan-abhishek wants to merge 2 commits into
Conversation
…h and query For the passthrough protocol ai-proxy forwards the client's request method, path and query string verbatim, so they select the upstream endpoint. The cache fingerprint only covered the body and instance config, so the same body sent to two different upstream paths (or with different query parameters) shared one cache entry. Fold the three into the fingerprint under the passthrough gate; other protocols are unchanged.
ctx.var.request_method is cached at route match, before a proxy-rewrite method change, while ai-proxy forwards the live method. Use core.request.get_method() so the fingerprint matches the upstream request, and cover a proxy-rewrite method rewrite in the passthrough cache tests.
nic-6443
approved these changes
Aug 27, 2026
AlinsRan
approved these changes
Aug 31, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
For the
passthroughprotocol,ai-proxyforwards 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. Theai-cachefingerprint covered only the client body and the instance config, so the same body sent to/v1/images/generationsand/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,
uriandargsintobuild_reprunder 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.luaunit block (path, query and method each flip the passthrough fingerprint; theopenai-chatfingerprint 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_keynote inai-cache.md(en/zh) now states that passthrough keys include the method, path and query.Which issue(s) this PR fixes:
Fixes #
Checklist