Repository navigation
fix: use inbound request body in set_if_absent body overrides, close #2133 - #2499
Conversation
…ooplj#2133 set_if_absent checked only the transformed outbound body, so a field the client sent was overwritten whenever format transformation dropped or remapped it (e.g. Anthropic thinking -> reasoning_effort). Also consult the original inbound request body so a client-provided field counts as present, keeping set_if_absent a default that clients can override.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review. 📝 WalkthroughWalkthroughThe body override pipeline now records valid JSON from the original request and passes it to ChangesBody override behavior
Priority: ➖ Normal Estimated code review effort: 3 (Moderate) | ~20 minutes Change: Bug fix · Severity of issue fixed: Medium Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 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 |
…ooplj#2133 (looplj#2499) set_if_absent checked only the transformed outbound body, so a field the client sent was overwritten whenever format transformation dropped or remapped it (e.g. Anthropic thinking -> reasoning_effort). Also consult the original inbound request body so a client-provided field counts as present, keeping set_if_absent a default that clients can override. Co-authored-by: remote-controlled-man <[email protected]>
Close #2133.
Problem
set_if_absentis documented as "set field value only when the target path does not exist — provide a default that clients can override". However, the absence check ran only against the transformed outbound body. When inbound→outbound format transformation drops or remaps a field the client sent (e.g. an Anthropicthinkingblock mapped toreasoning_effortfor the upstream channel), the path is absent from the outbound body, soset_if_absentapplied its configured default and overwrote a parameter the client had explicitly provided.Fix
applyBodySetIfAbsentnow also consults the original inbound request body (llm.Request.RawRequest.Body, already captured byPersistentInboundTransformer.TransformRequest): a field present in either the original or the transformed body counts as present, and an explicitnullstill counts as present. Non-JSON or unavailable original bodies fall back to the previous behavior.All other override ops, header overrides, conditions/templates, and the non-JSON-body guard are unchanged.
Tests
TestOverrideBodySetIfAbsentOriginalRequestreproduces the issue scenario (client sendsthinking, transformed body drops it, override must not re-add it) plus explicit-null, nested-path, both-absent, transformed-only, non-JSON-original, and no-original-request cases.go test ./internal/server/orchestrator/...andgo test ./internal/server/... ./internal/objects/...pass.