Repository navigation
Conversation
Greptile SummaryThis PR adds observability logging to the non-BYOK Gemini proxy paths by converting the existing direct returns into a two-step pattern:
Confidence Score: 4/5Safe to merge; the refactor is mechanically correct and introduces no behavioral regression — the only concern is that the new log line fires for all upstream HTTP responses, not just 2xx. The change is narrow: two return sites are converted from a direct return into await?/log/Ok(response). The ? propagation is correct, ownership and lifetimes are unaffected, and there is no change to error handling paths. The one gap is that both gemini_proxy_server_key and gemini_stream_server_key return Ok(response) for any upstream HTTP status, so the forwarded log will also appear when Gemini returns a 429 or 500 — a misleading signal when debugging user-facing errors. desktop/Backend-Rust/src/routes/proxy.rs — specifically the two new tracing::info! sites at the non-BYOK return paths. Important Files Changed
Sequence DiagramsequenceDiagram
participant Client
participant gemini_proxy
participant gemini_proxy_server_key
participant Upstream
Client->>gemini_proxy: "POST /v1/proxy/gemini/*path"
Note over gemini_proxy: Auth, allowlist, sanitize, rate limit
alt Non-BYOK path (this PR)
gemini_proxy->>gemini_proxy_server_key: .await?
gemini_proxy_server_key->>Upstream: forward with server key
Upstream-->>gemini_proxy_server_key: response (any HTTP status)
gemini_proxy_server_key-->>gemini_proxy: Ok(response)
Note over gemini_proxy: NEW: tracing::info!(uid, path) fires for ANY status
gemini_proxy-->>Client: Ok(response)
else BYOK path
gemini_proxy->>Upstream: forward with user API key
Upstream-->>gemini_proxy: response
gemini_proxy-->>Client: response (no log)
end
Reviews (1): Last reviewed commit: "fix(desktop): log Gemini proxy forwarded..." | Re-trigger Greptile |
| let response = gemini_proxy_server_key( | ||
| &state, &user, &effective_path, action, model, &sanitized_body, | ||
| ) | ||
| .await; | ||
| .await?; | ||
| tracing::info!( | ||
| "gemini_proxy: forwarded uid={} path={}", | ||
| user.uid, | ||
| effective_path | ||
| ); | ||
| return Ok(response); |
There was a problem hiding this comment.
The log fires for every completed upstream HTTP exchange, including 4xx/5xx responses from the Gemini API. Both
gemini_proxy_server_key and gemini_stream_server_key return Ok(response) even when the upstream status is an error — the ? only propagates network-level ProxyErrors. This means a Gemini-returned 429 or 500 will still produce a "forwarded" log line, which could be misleading when correlating logs with user-facing errors. The PR description says "log successful … forwards"; checking response.status().is_success() before emitting the line would match that intent.
| let response = gemini_proxy_server_key( | |
| &state, &user, &effective_path, action, model, &sanitized_body, | |
| ) | |
| .await; | |
| .await?; | |
| tracing::info!( | |
| "gemini_proxy: forwarded uid={} path={}", | |
| user.uid, | |
| effective_path | |
| ); | |
| return Ok(response); | |
| let response = gemini_proxy_server_key( | |
| &state, &user, &effective_path, action, model, &sanitized_body, | |
| ) | |
| .await?; | |
| if response.status().is_success() { | |
| tracing::info!( | |
| "gemini_proxy: forwarded uid={} path={}", | |
| user.uid, | |
| effective_path | |
| ); | |
| } | |
| return Ok(response); |
| let response = gemini_stream_server_key( | ||
| &state, | ||
| &effective_path, | ||
| action, | ||
| model, | ||
| sanitized_body, | ||
| &query, | ||
| ) | ||
| .await?; | ||
| tracing::info!( | ||
| "gemini_stream_proxy: forwarded uid={} path={}", | ||
| user.uid, | ||
| effective_path | ||
| ); | ||
| return Ok(response); |
There was a problem hiding this comment.
Same semantic issue for the streaming path:
gemini_stream_server_key returns Ok(response) regardless of whether the upstream status is 2xx, 4xx, or 5xx, so the "forwarded" log fires even when the downstream client will receive an error stream. Additionally, for the streaming case, the log fires as soon as the response headers are received from the upstream — before any SSE body chunks are delivered — which is the earliest practical logging point but worth noting in a follow-up if per-stream-completion logging is ever needed.
| let response = gemini_stream_server_key( | |
| &state, | |
| &effective_path, | |
| action, | |
| model, | |
| sanitized_body, | |
| &query, | |
| ) | |
| .await?; | |
| tracing::info!( | |
| "gemini_stream_proxy: forwarded uid={} path={}", | |
| user.uid, | |
| effective_path | |
| ); | |
| return Ok(response); | |
| let response = gemini_stream_server_key( | |
| &state, | |
| &effective_path, | |
| action, | |
| model, | |
| sanitized_body, | |
| &query, | |
| ) | |
| .await?; | |
| if response.status().is_success() { | |
| tracing::info!( | |
| "gemini_stream_proxy: forwarded uid={} path={}", | |
| user.uid, | |
| effective_path | |
| ); | |
| } | |
| return Ok(response); |
Summary
uidand forwardedpathFixes #7624.
Verification
git diff --checkNot run locally:
cargo check && cargo testbecause this Windows host does not havecargo/rustcinstalled.