Skip to content

fix(provider-openai): remove X-Aisix-Bridge outbound diagnostic header - #380

Merged
moonming merged 1 commit into
mainfrom
fix/remove-x-aisix-bridge-header
May 22, 2026
Merged

fix(provider-openai): remove X-Aisix-Bridge outbound diagnostic header#380
moonming merged 1 commit into
mainfrom
fix/remove-x-aisix-bridge-header

Conversation

@moonming

@moonming moonming commented May 22, 2026

Copy link
Copy Markdown
Collaborator

fix(provider-openai): remove X-Aisix-Bridge outbound diagnostic header

The header was added in AISIX-Cloud#368 as an e2e probe to detect
Hub.register typos — e.g. OpenAiBridge::new().with_name("grop")
registered under Provider::Groq would manifest as the wrong
header value on the captured outbound request.

After Phase A clean cut (#375 closing AISIX-Cloud#417), 11 of the
14 OpenAI-adapter providers (groq / mistral / togetherai /
fireworks-ai / perplexity / moonshotai / alibaba / zhipuai /
baseten / huggingface / cerebras) no longer have a distinguishable
per-vendor with_name() identity — they all share the OpenAI
family bridge with uniform name "openai". The typo signal is no
longer testable for them.

The 3 remaining specialized bridges (google / deepseek / cohere)
do still carry distinct with_name labels, and removing the
header drops their typo-detection too. The user-driven design call
(per AISIX-Cloud#468 thread) is that operator-side diagnostics are
already covered by the DP's tracing::info! bridge=<name> field
on dispatch + chunk-stream spans — surfacing the same identity via
the upstream wire was a duplicate signal whose narrow remaining
value (3 of 14 providers) doesn't justify the per-request header
overhead, the customer-facing override-protection plumbing in
overrides.rs::RESERVED_DEFAULT_HEADERS, or the four in-crate
tests pinning behavior.

Changes:

  • build_request_headers: drop bridge_name parameter + insert
  • 4 inline header() call sites removed with their let setup
  • build_chunk_stream keeps bridge_name (tracing::warn! span field,
    NOT outbound header)
  • 4 in-crate tests removed:
    chat_default_headers_cannot_override_x_aisix_bridge
    chat_emits_x_aisix_bridge_openai_for_default_bridge
    chat_emits_x_aisix_bridge_for_with_name_variant
    chat_stream_emits_x_aisix_bridge_for_with_name_variant
  • RESERVED_DEFAULT_HEADERS: drop "x-aisix-bridge" entry

Verified:

  • cargo build --workspace clean
  • cargo test -p aisix-provider-openai -> 85 passed

Pairs with AISIX-Cloud#468 which drops the corresponding e2e
assertions on the test side. AISIX-Cloud#468 is forward-compatible
with header absence; this PR removes the header at the source.


Pairs with api7/AISIX-Cloud#468 which drops the corresponding e2e assertions on the test side. AISIX-Cloud#468 is forward-compatible with header absence; this PR removes the header at the source.

Summary by CodeRabbit

  • Refactor

    • Simplified request header handling in the OpenAI provider integration by removing automatic diagnostic header emission and reducing configuration parameters. Header construction now focuses on authentication and streaming requirements.
  • Tests

    • Removed diagnostic header validation tests reflecting updated header handling approach.

Review Change Stack

The header was added in AISIX-Cloud#368 as an e2e probe to detect
Hub.register typos — e.g. `OpenAiBridge::new().with_name("grop")`
registered under `Provider::Groq` would manifest as the wrong
header value on the captured outbound request.

After Phase A clean cut (#375 closing AISIX-Cloud#417), 11 of the
14 OpenAI-adapter providers (groq / mistral / togetherai /
fireworks-ai / perplexity / moonshotai / alibaba / zhipuai /
baseten / huggingface / cerebras) no longer have a distinguishable
per-vendor `with_name()` identity — they all share the OpenAI
family bridge with uniform name "openai". The typo signal is no
longer testable for them.

The 3 remaining specialized bridges (google / deepseek / cohere)
do still carry distinct `with_name` labels, and removing the
header drops their typo-detection too. The user-driven design call
(per AISIX-Cloud#468 thread) is that operator-side diagnostics are
already covered by the DP's `tracing::info!` `bridge=<name>` field
on dispatch + chunk-stream spans — surfacing the same identity via
the upstream wire was a duplicate signal whose narrow remaining
value (3 of 14 providers) doesn't justify the per-request header
overhead, the customer-facing override-protection plumbing in
`overrides.rs::RESERVED_DEFAULT_HEADERS`, or the four in-crate
tests pinning behavior.

Changes:
  - build_request_headers: drop bridge_name parameter + insert
  - 4 inline header() call sites removed with their let setup
  - build_chunk_stream keeps bridge_name (tracing::warn! span field,
    NOT outbound header)
  - 4 in-crate tests removed:
      chat_default_headers_cannot_override_x_aisix_bridge
      chat_emits_x_aisix_bridge_openai_for_default_bridge
      chat_emits_x_aisix_bridge_for_with_name_variant
      chat_stream_emits_x_aisix_bridge_for_with_name_variant
  - RESERVED_DEFAULT_HEADERS: drop "x-aisix-bridge" entry

Verified:
  - cargo build --workspace clean
  - cargo test -p aisix-provider-openai -> 85 passed

Pairs with AISIX-Cloud#468 which drops the corresponding e2e
assertions on the test side. AISIX-Cloud#468 is forward-compatible
with header absence; this PR removes the header at the source.
Copilot AI review requested due to automatic review settings May 22, 2026 11:54
@coderabbitai

coderabbitai Bot commented May 22, 2026

Copy link
Copy Markdown
ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Free

Run ID: 8775c552-2bde-4bcd-a073-441dca86b61d

📥 Commits

Reviewing files that changed from the base of the PR and between 91a0567 and 0d8adda.

📒 Files selected for processing (2)
  • crates/aisix-provider-openai/src/bridge.rs
  • crates/aisix-provider-openai/src/overrides.rs
💤 Files with no reviewable changes (1)
  • crates/aisix-provider-openai/src/overrides.rs

📝 Walkthrough

Walkthrough

The PR removes the x-aisix-bridge diagnostic header from OpenAI bridge outbound requests. The build_request_headers function signature is simplified by removing the bridge_name parameter. All request methods update their call sites accordingly. The reserved headers allowlist removes x-aisix-bridge, and related unit tests asserting its presence are removed.

Changes

Diagnostic Header Removal

Layer / File(s) Summary
Header construction simplification
crates/aisix-provider-openai/src/bridge.rs
build_request_headers removes the bridge_name parameter and stops inserting the x-aisix-bridge header. Documentation is updated to reflect that only Authorization, Content-Type, x-aisix-request-id, and conditional SSE Accept headers are set before merging operator default_headers.
Request method call site updates
crates/aisix-provider-openai/src/bridge.rs
The chat, chat_stream, embed, complete, and generate_image request methods are updated to stop passing self.name to build_request_headers.
Override settings and test cleanup
crates/aisix-provider-openai/src/overrides.rs, crates/aisix-provider-openai/src/bridge.rs
RESERVED_DEFAULT_HEADERS removes x-aisix-bridge from the protected headers list. Tests verifying x-aisix-bridge presence and override defense are removed, with a comment documenting the removal.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes


Note

🎁 Summarized by CodeRabbit Free

Your organization has reached its limit of developer seats under the Pro Plan. For new users, CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please add seats to your subscription by visiting https://app.coderabbit.ai/login.If you believe this is a mistake and have available seats, please assign one to the pull request author through the subscription management page using the link above.

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

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Removes the X-Aisix-Bridge diagnostic header from outbound requests in aisix-provider-openai, aligning with the Phase A “family bridge” shift where most OpenAI-adapter providers no longer have distinct per-vendor bridge names and bridge identity is already available via tracing spans.

Changes:

  • Drops x-aisix-bridge insertion from OpenAiBridge outbound request building (including chat + non-chat paths shown in the diff).
  • Removes x-aisix-bridge from RESERVED_DEFAULT_HEADERS.
  • Deletes the in-crate unit tests that asserted x-aisix-bridge emission / non-overridable behavior.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
crates/aisix-provider-openai/src/overrides.rs Removes x-aisix-bridge from the reserved header denylist used by apply_default_headers.
crates/aisix-provider-openai/src/bridge.rs Stops emitting x-aisix-bridge on outbound requests and removes tests tied to the header contract.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +463 to +466
/// spans. Customer default_headers can no longer set this header
/// (per overrides.rs allowlist, also pruned), upstream APIs don't
/// read it, and the original #368 catch-Hub-typo motivation became
/// untestable for the family-keyed providers.
@moonming
moonming merged commit 4d09ae7 into main May 22, 2026
9 checks passed
moonming added a commit that referenced this pull request May 22, 2026
Pulls in #380 (remove X-Aisix-Bridge outbound diagnostic header) which
merged after this branch was created. Conflict in
crates/aisix-provider-openai/src/bridge.rs resolved by taking main's
deletion side at every hunk — #380 removes the `x-aisix-bridge` header
+ its `bridge_name` parameter / locals / tests entirely, which is a
superset of the per-vendor → canonical-bridge-name change this PR
introduced. Net result: no x-aisix-bridge handling left in the bridge.

Also strips `x-aisix-bridge` from the RESERVED_DEFAULT_HEADERS
allowlist in overrides.rs (carried in from main's #380).

cargo fmt + clippy --all-targets -- -D warnings + test --workspace
all green after merge.
@jarvis9443
jarvis9443 deleted the fix/remove-x-aisix-bridge-header branch June 25, 2026 06:26
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.

2 participants