Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# dependencies = [
# "aiohttp",
# "arize-phoenix-otel",
# "multidict",
# "opentelemetry-api",
# "opentelemetry-sdk",
# "pyyaml",
Expand All @@ -12,17 +13,18 @@

import json
import logging
import yaml
from typing import Dict, Any, List

from aiohttp import web
import aiohttp

from multidict import CIMultiDict
from opentelemetry import trace
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import BatchSpanProcessor
from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter
from opentelemetry.sdk.resources import Resource
from openinference.semconv.trace import SpanAttributes
import yaml

# Configure logging
logging.basicConfig(level=logging.INFO)
Expand Down Expand Up @@ -285,10 +287,14 @@ async def handle_generate_content(request):
response_json.get("usageMetadata", {}).get("totalTokenCount", 0),
)

mutable_headers = CIMultiDict(upstream_response.headers)
mutable_headers.pop('Transfer-Encoding', None)
mutable_headers.pop('Content-Encoding', None)

Comment on lines +290 to +293
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

# First, get an overview of the proxy.py file structure and handler locations
head -300 proxy.py | tail -50

Repository: QuixiAI/VibeLogger

Length of output: 2675


🏁 Script executed:

# Look at the specific section around lines 290-293
sed -n '285,305p' proxy.py

Repository: QuixiAI/VibeLogger

Length of output: 968


🏁 Script executed:

# Check the structure of other handlers mentioned
sed -n '325,345p' proxy.py
sed -n '455,475p' proxy.py
sed -n '620,640p' proxy.py

Repository: QuixiAI/VibeLogger

Length of output: 2644


Apply the same header cleanup to other proxy handlers for consistency.

The fix at lines 290-293 correctly removes Transfer-Encoding and Content-Encoding headers from the Gemini response. However, the same cleanup should be applied to handle_list_models, handle_anthropic_request, and handle_openai_request, which currently pass upstream headers directly without removing these encoding headers. If the gzip encoding issue affects proxied responses, it affects all handlers and should be handled consistently.

🧰 Tools
🪛 Ruff (0.14.10)

290-290: Undefined name CIMultiDict

(F821)

🤖 Prompt for AI Agents
In proxy.py around lines 290-293 and in the handlers handle_list_models,
handle_anthropic_request, and handle_openai_request, the upstream response
headers are currently forwarded as-is; replicate the same header cleanup used at
lines 290-293 by creating a mutable copy of upstream_response.headers, removing
'Transfer-Encoding' and 'Content-Encoding' with pop(..., None), and use that
cleaned headers mapping when constructing the proxied response so all proxy
handlers consistently strip those encoding headers; also handle cases where
upstream_response or headers may be missing before copying.

return web.Response(
status=upstream_response.status,
body=response_body,
headers=dict(upstream_response.headers),
headers=mutable_headers,
)

except Exception as e:
Expand Down