fix(antigravity): allow cloudcode envelope through messages guard - #7582
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces support for the mitmRouteAlias namespace in src/mitm/server.cjs to separate client-facing OmniRoute model IDs from mitmAlias, prioritizing it during model mapping. Additionally, it updates src/sse/handlers/chat.ts to identify Antigravity requests by path and bypass the early validation guard requiring messages or input fields, as Antigravity requests utilize a cloudcode request envelope. Corresponding unit tests have been added to validate the routing behavior and the alias resolution order. No review comments were provided, so there is no feedback to address.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
|
Thanks for tracking down the cloudcode-envelope guard bug — the chat.ts fix (bypassing the OpenAI The src/mitm/server.cjs half has drifted, though: |
|
Rebased onto the current
Validation: node --check src/mitm/server.cjs
node --check src/mitm/_internal/routeAlias.cjs
node --import tsx/esm --test tests/unit/mitm-server-antigravity-route-alias.test.ts tests/unit/mitm-alias-config-shim.test.ts tests/unit/mitm-antigravity-reasoning-effort-override.test.ts tests/unit/chat-messages-validation-6402.test.tsResult: 50/50 tests passed. Current PR state: mergeable, Semgrep passed. |
7c16f71 to
aa39a6f
Compare
5a5c413 to
c57e07a
Compare
…under cap resolveChatSourceFormatForPath() in chat.ts duplicated the exact antigravity-path regex already in detectFormatFromEndpoint() (open-sse/services/provider.ts) — the added function pushed chat.ts to 1808 lines, over the frozen file-size cap of 1797, with no baseline bump. Remove the duplicate: add a thin detectFormatFromUrl(body, requestUrl) wrapper next to detectFormatFromEndpoint (single source of truth for the path/body-based format detection), and have chat.ts call it directly. Also drop the now-single-use FORMATS import (compare against the literal "antigravity", matching the existing convention in chatHelpers.ts) and remove an unneeded block-scope around the pre-existing diegosouzapw#6402 messages guard (renamed its local to msgBody — a second, separate `const b` block further down for temperature/top_p/max_tokens/n validation is untouched and does not collide). Net effect: chat.ts 1808 -> 1797 lines (exactly at the frozen cap, no baseline change). Behavior is unchanged — same tests, same guard logic, same antigravity bypass. Re-verified full green: typecheck:core, eslint, file-size/complexity/cognitive-complexity/complexity-ratchets/changelog- integrity/test-discovery gates, and the PR's own regression suites (chat-messages-validation-6402.test.ts 26/26, mitm-server-antigravity- route-alias.test.ts 4/4), plus the adjacent format-detection and chat-pipeline test suites. Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com>
…guard Resolve conflict in src/mitm/server.cjs: release's standaloneRouting.cjs (multi-agent alias resolution, merged via diegosouzapw#7408's cycle) supersedes this PR's mitmRouteAlias-only routeAlias.cjs, so drop the latter and its now-orphaned unit test in favor of the release-side module. Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com>
9fce7d0
into
diegosouzapw:release/v3.8.49
|
Merged into |
…egosouzapw#7582) * fix(antigravity): allow cloudcode envelope through guard * fix(sse): dedupe antigravity source-format detection, shrink chat.ts under cap resolveChatSourceFormatForPath() in chat.ts duplicated the exact antigravity-path regex already in detectFormatFromEndpoint() (open-sse/services/provider.ts) — the added function pushed chat.ts to 1808 lines, over the frozen file-size cap of 1797, with no baseline bump. Remove the duplicate: add a thin detectFormatFromUrl(body, requestUrl) wrapper next to detectFormatFromEndpoint (single source of truth for the path/body-based format detection), and have chat.ts call it directly. Also drop the now-single-use FORMATS import (compare against the literal "antigravity", matching the existing convention in chatHelpers.ts) and remove an unneeded block-scope around the pre-existing diegosouzapw#6402 messages guard (renamed its local to msgBody — a second, separate `const b` block further down for temperature/top_p/max_tokens/n validation is untouched and does not collide). Net effect: chat.ts 1808 -> 1797 lines (exactly at the frozen cap, no baseline change). Behavior is unchanged — same tests, same guard logic, same antigravity bypass. Re-verified full green: typecheck:core, eslint, file-size/complexity/cognitive-complexity/complexity-ratchets/changelog- integrity/test-discovery gates, and the PR's own regression suites (chat-messages-validation-6402.test.ts 26/26, mitm-server-antigravity- route-alias.test.ts 4/4), plus the adjacent format-detection and chat-pipeline test suites. Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com> --------- Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com>
…egosouzapw#7582) * fix(antigravity): allow cloudcode envelope through guard * fix(sse): dedupe antigravity source-format detection, shrink chat.ts under cap resolveChatSourceFormatForPath() in chat.ts duplicated the exact antigravity-path regex already in detectFormatFromEndpoint() (open-sse/services/provider.ts) — the added function pushed chat.ts to 1808 lines, over the frozen file-size cap of 1797, with no baseline bump. Remove the duplicate: add a thin detectFormatFromUrl(body, requestUrl) wrapper next to detectFormatFromEndpoint (single source of truth for the path/body-based format detection), and have chat.ts call it directly. Also drop the now-single-use FORMATS import (compare against the literal "antigravity", matching the existing convention in chatHelpers.ts) and remove an unneeded block-scope around the pre-existing diegosouzapw#6402 messages guard (renamed its local to msgBody — a second, separate `const b` block further down for temperature/top_p/max_tokens/n validation is untouched and does not collide). Net effect: chat.ts 1808 -> 1797 lines (exactly at the frozen cap, no baseline change). Behavior is unchanged — same tests, same guard logic, same antigravity bypass. Re-verified full green: typecheck:core, eslint, file-size/complexity/cognitive-complexity/complexity-ratchets/changelog- integrity/test-discovery gates, and the PR's own regression suites (chat-messages-validation-6402.test.ts 26/26, mitm-server-antigravity- route-alias.test.ts 4/4), plus the adjacent format-detection and chat-pipeline test suites. Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com> --------- Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com>
Summary
Closes #7581.
This fixes two Antigravity MITM routing problems:
/v1/antigravitycloudcode envelopes no longer get rejected by the OpenAI top-levelmessagesguard. Antigravity requests carry turns underrequest.contents, so missing top-levelmessagesis valid for this endpoint.mitmRouteAlias.antigravitynamespace and only falls back tomitmAlias.antigravity, keeping MITM model routing separate from executor upstream-id cleanup while preserving compatibility.Verification
Ran targeted regression tests:
Result:
31/31tests passed.The Antigravity cloudcode regression loop covers the Gemini-family model set derived from
ANTIGRAVITY_PUBLIC_MODELS,AGY_PUBLIC_MODELS, andANTIGRAVITY_MODEL_ALIASES/values. It currently verifies 21 model IDs, includinggemini-3.5-flash-low,gemini-3.5-flash-medium,gemini-3.5-flash-high,gemini-3.1-pro-high,gemini-3.1-pro-low,gemini-pro-agent, andrev19-uic3-1p, and asserts they route through the Antigravity executor without returning the missing-messages 400.