Uh oh!
There was an error while loading. Please reload this page.
feat(vertex): wire RequestOverrides on the Vertex bridge (#302 §5, #339) - #460
Conversation
Mirror OpenAiBridge's apply pipeline on all five Vertex publisher rails (Gemini / Anthropic / OpenAI-compat shim / Mistral / AI21, non-stream + streaming): param_renames -> param_constraints -> default_body_fields -> content_list_to_string on the outbound body, and default_headers on the outbound headers. All primitives are no-ops when the targeted keys are absent, so the pipeline is safe to call uniformly across the rails. The body pipeline runs BEFORE the rail-specific shaping (the Anthropic model/stream strip), so an override can never reintroduce a URL-borne `model` into a :rawPredict body. default_headers reuses the shared guard in apply_default_headers, so it can never clobber the minted OAuth Bearer or any reserved auth header. Reuses the pub primitives from aisix-provider-openai::overrides (the same ones OpenAiBridge calls) so cp-api configures one wire shape for every adapter. Tests: 6 wiremock round-trips assert the recorded body / headers reflect each override across the Gemini, shim, and Anthropic rails, plus the reserved-auth guard and the model-strip ordering invariant.
Warning Review limit reached
More reviews will be available in 6 minutes and 38 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Free Run ID: 📒 Files selected for processing (1)
Note 🎁 Summarized by CodeRabbit FreeYour 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 |
Independent pre-merge audit of #460 flagged two MEDIUM test-coverage gaps (production wiring itself verified correct on all 8 rails): - MEDIUM-1: the `content_list_to_string` branch (gated on the response override block) was unverified on Vertex. - MEDIUM-2: the streaming body-build path and the partner `:rawPredict` URL builder rail had no override regression test — a rail dropping the override call would still pass. Adds 3 wiremock round-trips: - openai_shim_stream_applies_default_body_fields — the streaming serialize path applies overrides; stream:true stays in the body - mistral_request_applies_default_body_fields_and_keeps_model_in_body — the partner :rawPredict rail applies overrides without disturbing the in-body model - openai_shim_response_content_list_to_string_flattens_outbound_body — the response-gated array->string content flatten reaches the wire 90 tests pass; clippy clean.
moonming
commented
Jun 1, 2026
Independent pre-merge audit (CLAUDE.md §8) returned BLOCK on two MEDIUM test-coverage findings (production wiring verified correct + secure + panic-free on all 8 rails). Both resolved in the follow-up commit:
90 tests pass; |
Uh oh!
There was an error while loading. Please reload this page.
What
Wires the per-
ProviderKeyRequestOverrides pipeline (issue #302 §5 RuntimeConfig) into the Vertex bridge, mirroringOpenAiBridgestep-for-step. Until now the override primitives existed (aisix-provider-openai::overrides) and the OpenAI bridge applied them, but the Vertex bridge ignoredprovider_key.request/.responseentirely — a Vertex BYO/catalog key could configure overrides and they'd silently no-op.Closes#339.
Contract pinned
Applied on all five publisher rails (8 dispatch methods:
chat_gemini+_stream,chat_anthropic+_stream,chat_openai_shim+_stream,chat_mistral_ai21+_stream):Outbound body (
apply_body_overrides, mirrorsOpenAiBridge::prepare_outbound_body):param_renames→ 2.param_constraints→ 3.default_body_fields→ 4.content_list_to_string(when the response override sets it)Outbound headers (
build_request_headers, mirrors the OpenAI builder):default_headersapplied last via the sharedapply_default_headers, which drops reserved auth headers and refuses to overwrite an already-set header.Ordering invariant
The body pipeline runs before the Vertex rail-specific shaping (the Anthropic
model/streamstrip), so adefault_body_fieldsblock can never reintroduce a URL-bornemodelinto a:rawPredictbody.default_headerscan never clobber the minted GCP OAuth Bearer (reserved-header guard + already-present guard, double protection).All four body primitives are no-ops when the targeted top-level keys are absent, so applying them uniformly is safe across the heterogeneous rails (the Gemini
contentsshape simply doesn't match the OpenAI-style keys the request transforms target —default_body_fields/default_headersstill apply there).Reference implementation
OpenAiBridge::prepare_outbound_body+build_request_headers—crates/aisix-provider-openai/src/bridge.rs(the apply order + reserved-header guard this PR mirrors).crates/aisix-provider-openai/src/overrides.rs(unchanged; reused verbatim via the crate'spub mod overrides).Tests
6 wiremock round-trips assert the recorded outbound body / headers reflect each override:
gemini_request_applies_default_body_fields— injected top-level field lands,contentspreservedgemini_request_applies_default_headers— added header reaches the wiredefault_headers_cannot_overwrite_vertex_bearer_auth— anauthorizationdefault can't displace the minted Bearer; non-reserved companion still appliesopenai_shim_request_applies_param_renames—temperature→ renamed key, source goneopenai_shim_request_applies_param_constraints— over-maxtemperatureclampedanthropic_request_overrides_run_before_model_strip—default_body_fields.modelstays stripped, a genuine extra field lands,anthropic_versionshaping still runscargo test -p aisix-provider-vertex→ 87 passed.cargo clippy --all-targetsclean.cargo fmtapplied.🤖 Generated with Claude Code