fix(ai-proxy): request identity encoding for translated streams#14893
Open
benissimo wants to merge 1 commit into
Open
fix(ai-proxy): request identity encoding for translated streams#14893benissimo wants to merge 1 commit into
benissimo wants to merge 1 commit into
Conversation
8dce523 to
04270da
Compare
Author
|
Bump, it's been 2 weeks, is anyone available to review this? |
Author
|
@rolandatkong If you have a chance to review this, please let me know. |
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.
Summary
Translated AI Proxy streaming paths can break when an upstream returns gzip-compressed SSE. This change requests
Accept-Encoding: identityonly when Kong is both:Provider-specific
Accept-Encodingbehavior remains in place for non-streaming requests and preserve/pass-through streaming routes.Why
Compressed SSE is safe when Kong can pass bytes through untouched. It is unsafe when Kong must parse and transform streaming frames because the parser needs raw SSE frames incrementally.
A concrete failure mode reproduced locally with an OpenAI-compatible upstream:
200+Content-Encoding: gzip+ empty/unusable bodyRequesting identity encoding for translated streams avoids negotiating gzip for the path that Kong must parse/transform.
Validation
Tested against a local
kong/kong-gateway:3.14Docker repro using the baseai-proxyplugin with an OpenAI-compatible upstream URL.Before patch:
200, JSON body200,Content-Type: text/event-stream,Content-Encoding: gzip, 0-byte bodyAfter patch, overlaying the central
normalize-request.luachange into the same container/config:200, JSON body200,Content-Type: text/event-stream, noContent-Encoding: gzip, readable SSE bodyExample downstream SSE after patch:
Tests
Updated streaming integration coverage to assert:
Accept-Encoding: identityAccept-Encoding: gzip, identityI could not run the upstream
bin/bustedtarget in this local checkout because the Kong dev runtime is not installed (env: resty: No such file or directory). I did rungit diff --checkand validated the behavior in Docker as described above.