Skip to content

fix: use inbound request body in set_if_absent body overrides, close #2133 - #2499

Merged
looplj merged 1 commit into
looplj:unstablefrom
remote-controlled-man:codex/axonhub-2133-set-if-absent-override
Sep 21, 2026
Merged

looplj merged 1 commit into
looplj:unstablefrom
remote-controlled-man:codex/axonhub-2133-set-if-absent-override

Conversation

@remote-controlled-man

@remote-controlled-man remote-controlled-man commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor

Close #2133.

Problem

set_if_absent is 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 Anthropic thinking block mapped to reasoning_effort for the upstream channel), the path is absent from the outbound body, so set_if_absent applied its configured default and overwrote a parameter the client had explicitly provided.

Fix

applyBodySetIfAbsent now also consults the original inbound request body (llm.Request.RawRequest.Body, already captured by PersistentInboundTransformer.TransformRequest): a field present in either the original or the transformed body counts as present, and an explicit null still 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

  • New middleware-level regression test TestOverrideBodySetIfAbsentOriginalRequest reproduces the issue scenario (client sends thinking, 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/... and go test ./internal/server/... ./internal/objects/... pass.

…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.
Copilot AI lite review requested due to automatic review settings September 19, 2026 04:09

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@coderabbitai

coderabbitai Bot commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: a0449bdc-51fd-4497-9358-e0c427913a62

📥 Commits

Reviewing files that changed from the base of the PR and between cb29b65 and c53eefb.

📒 Files selected for processing (2)
  • internal/server/orchestrator/override.go
  • internal/server/orchestrator/override_test.go

Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review.


📝 Walkthrough

Walkthrough

The body override pipeline now records valid JSON from the original request and passes it to set_if_absent. The operation skips fields present or null in the original body, including fields removed during transformation. Table-driven tests cover these cases.

Changes

Body override behavior

Layer / File(s) Summary
Capture and thread original body
internal/server/orchestrator/override.go
The pipeline captures valid JSON from llmReq.RawRequest and passes it through body operation processing.
Evaluate original body presence
internal/server/orchestrator/override.go, internal/server/orchestrator/override_test.go
set_if_absent checks fields in the original body, including explicit null and nested fields. Tests cover absent fields, transformed fields, non-JSON bodies, and missing original requests.

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix · Severity of issue fixed: Medium

Suggested reviewers: looplj

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 6 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Issue #2133 requires set_if_absent to preserve client-provided fields, including fields dropped or remapped during transformation. applyOverrideRequestBody now passes a valid original inbound JSON…
Out of Scope Changes check ✅ Passed The changes are limited to original-body handling in internal/server/orchestrator/override.go and regression tests in override_test.go. These changes directly support issue #2133 and introduce no …
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: using the inbound request body when evaluating set_if_absent body overrides. It also references the related issue.
  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@looplj looplj changed the title fix: honor client-sent fields in set_if_absent body overrides, close #2133 fix: use inbound request body in set_if_absent body overrides, close #2133 Sep 21, 2026
@looplj
looplj merged commit c8b3a7e into looplj:unstable Sep 21, 2026
6 checks passed
Edint386 pushed a commit to Edint386/axonhub that referenced this pull request Oct 9, 2026
…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]>
@remote-controlled-man
remote-controlled-man deleted the codex/axonhub-2133-set-if-absent-override branch October 13, 2026 01:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug/错误]: set_if_absent 覆盖重写操作失效

3 participants