bugfix: log routing and sticky session decisions#182
Conversation
Affinity and routing outcomes were only set on X-Olla-* response headers, so logs gave no way to see which backend a request landed on or why. The completion log now carries sticky_outcome, the routing strategy/action/reason, provider_model and the translation fallback reason. session_id and sticky_source stay at DEBUG since the session id is client-supplied. The sticky session test is now a self-contained skill rather than a loose markdown file plus bash harness.
WalkthroughExtends proxy and translation request handlers to capture sticky-session routing metadata ( ChangesSticky Session Metadata in Request Logging
Test Infrastructure Migration: Bash → Claude Skill
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related issues
Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
makefile (1)
21-21: ⚡ Quick winPhony targets are declared twice: consolidate to avoid maintenance confusion.
The targets
mock-up,mock-down,mock-status, andmock-logsappear in both the main.PHONYdeclaration at line 21 AND in a dedicated.PHONYblock at line 367. Whilst Make handles this without error, declaring a target in.PHONYonly once improves clarity. Suggest removing them from line 21 and keeping only the dedicated block at line 367 for organisational transparency.♻️ Proposed consolidation
-.PHONY: run clean build test test-verbose test-short test-race test-cover bench version install-deps check-deps vet test-script-integration test-script-sticky mock-up mock-down mock-status mock-logs test-auth-bearer test-auth-env-fatal test-auth-manual +.PHONY: run clean build test test-verbose test-short test-race test-cover bench version install-deps check-deps vet test-script-integration test-script-sticky test-auth-bearer test-auth-env-fatal test-auth-manualThis keeps the AIMock targets only in the dedicated
.PHONYblock at line 367, reducing duplication and improving readability.Also applies to: 367-367
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@makefile` at line 21, Remove the duplicate phony target declarations by deleting mock-up, mock-down, mock-status, and mock-logs from the main .PHONY declaration line that includes targets like run, clean, build, test, and others. Keep these four targets only in the dedicated .PHONY block reserved for AIMock-related targets to maintain organizational clarity and eliminate the duplication.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@internal/app/handlers/handler_translation.go`:
- Around line 92-95: The context value for constants.ContextStickyOutcomeKey is
being written as *balancer.StickyOutcome type in the injectStickyKeyWithBody
function, but is being read as *domain.StickyOutcome type in both the handler
code around line 92 and another location around line 259. This type mismatch
causes the type assertion to fail silently, preventing the sticky outcome and
source from being populated. Change both type assertions from
*domain.StickyOutcome to *balancer.StickyOutcome to match the actual type being
stored in the context.
---
Nitpick comments:
In `@makefile`:
- Line 21: Remove the duplicate phony target declarations by deleting mock-up,
mock-down, mock-status, and mock-logs from the main .PHONY declaration line that
includes targets like run, clean, build, test, and others. Keep these four
targets only in the dedicated .PHONY block reserved for AIMock-related targets
to maintain organizational clarity and eliminate the duplication.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: ab84eb4c-5327-43d9-a27f-54b2cf98097e
📒 Files selected for processing (9)
.claude/skills/test-sticky-sessions.md.claude/skills/test-sticky-sessions/SKILL.mdinternal/adapter/proxy/olla/service_retry.gointernal/app/handlers/handler_proxy.gointernal/app/handlers/handler_proxy_logging_test.gointernal/app/handlers/handler_translation.gomakefiletest/scripts/sticky/run-manual.shtest/scripts/sticky/test-sticky-provider-routes.sh
💤 Files with no reviewable changes (3)
- .claude/skills/test-sticky-sessions.md
- test/scripts/sticky/run-manual.sh
- test/scripts/sticky/test-sticky-provider-routes.sh
…#178) The issue reporter asked for session_id on the INFO line. It is only ever this client-supplied value (everywhere else the session is hashed before use), and sits beside sticky_outcome so a request can be traced end to end without enabling DEBUG.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@internal/app/handlers/handler_provider_test.go`:
- Around line 314-317: The multi-line comment for
TestProviderProxyHandler_StickyFieldsInCompletedLog contains an em dash (—) on
line 316 between "INFO log" and "the same class", which violates repository
style guidelines requiring Australian English with no em-dashes in comments.
Replace the em dash with either a comma or a full stop to maintain consistency
with the documentation rules.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 78e49f8a-0c58-42d7-9cfa-33bbf2b98bf9
📒 Files selected for processing (5)
internal/app/handlers/handler_provider_common.gointernal/app/handlers/handler_provider_test.gointernal/app/handlers/handler_proxy.gointernal/app/handlers/handler_proxy_logging_test.gointernal/app/handlers/handler_translation.go
🚧 Files skipped from review as they are similar to previous changes (3)
- internal/app/handlers/handler_translation.go
- internal/app/handlers/handler_proxy_logging_test.go
- internal/app/handlers/handler_proxy.go
Affinity and routing outcomes were only set on X-Olla-* response headers, so logs gave no way to see which backend a request landed on or why. The completion log now carries sticky_outcome, the routing strategy/action/reason, provider_model and the translation fallback reason. session_id and sticky_source stay at DEBUG since the session id is client-supplied.
Also took made the sticky session test is now a self-contained skill rather than a loose markdown file plus bash harness.
addresses issue #178.
Summary by CodeRabbit
Release Notes
New Features
Tests
Chores