Repository navigation
[PR] fix(wiring): restore a collapsed scheme slash in an embedded /bili/ URL - #8287
Open
yangwuan55 wants to merge 1 commit into
Open
yangwuan55 wants to merge 1 commit into
yangwuan55 wants to merge 1 commit into
Conversation
A client that normalises its base-URL path (Antigravity CLI: GOOGLE_GEMINI_BASE_URL `…/bili/http://host` reaches bili as `/bili/http:/host`) had its embedded URL dropped by resolveUpstream, which only accepted `http://` / `https://`; the request fell through to an opaque 403 "Request not allowed" with no log line naming the cause. Normalise `^(https?):\/*` to `$1://` before parsing, for both the bare `/bili/<url>` form and the `<protocol>/`-prefixed form. Well-formed URLs are returned byte-identical, so no existing lane changes behaviour. Closes ranxianglei#8286
This was referenced Dec 5, 2026
lbn2011
pushed a commit
to lbn2011/billion-context
that referenced
this pull request
Dec 5, 2026
Owner
[bot] 🏷 (ai: qwen4-35b-a3b) 查重: 不重复。Searched open+closed issues & PRs for this topic — the only related item is #8286, the bug issue this PR closes (intended relationship, not a duplicate). No parallel fix PR exists. Review verdict: 可合 (approve). I verified the fix independently end-to-end, not just by reading the diff. What I ran:
结构化八问
Non-blocking note: branch is 判定:可合。修复正确、最小、单模块、测试与 CI 全绿、e2e 实证通过;无回归、无缓存影响、无新配置面。未向 PR 分支追加任何 commit(未发现缺陷)。合并由 owner 执行。 |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #8286
What broke
resolveUpstreamaccepts an embedded/bili/URL only when it already starts withhttp:///https://. A client that normalises its base-URL path collapses the double slash, so the embedded URL arrives as/bili/http:/host/..., is not recognised as a tunnel, falls through all lanes and the request is answered with an opaque403 {"error":{"type":"forbidden","message":"Request not allowed"}}— no log line names the cause.Reproduced on 6d6ed9e (v0.1.218):
The concrete client is the Antigravity CLI (
agy1.5.24):GOOGLE_GEMINI_BASE_URL=http://127.0.0.1:8787/bili/http://127.0.0.1:3425is sent asPOST /bili/http:/127.0.0.1:3425/v1beta/models/…:streamGenerateContent?alt=sse. This is the only blocker for the magpie agy lane (yetone/magpie#7663), which assumes the/bili/prefix already works.Fix
src/server.ts— normalise the scheme of the candidate before parsing, for the bare/bili/<url>form and for the<protocol>/-prefixed form (/bili/google/<url>):Well-formed input round-trips byte-identical (
http://→http://), so no existing lane changes behaviour: the strict parse still runs first and only the collapsed shape gains a path.not-a-urlstill has no scheme and stays unroutable, keeping the existing negative test green.Tests
tests/zero-config-routing.test.ts— two cases: collapsed form on the bare prefix (assertsupstream,rewrittenUrl,tunnel) and collapsed form after thegoogle/protocol prefix (assertsupstream+explicitProtocol).Pre-flight (local)
node --import tsx --test tests/zero-config-routing.test.ts→ 7/7 pass (5 existing + 2 new)npm run typecheck→ cleannpm run build→ OK (dist-import-annotations: OK,dist-external: OK)Evidence (A/B, real traffic, not "should work")
Same bili build on
--port 8787, magpie gateway on127.0.0.1:3425:agy … -p "reply exactly: collapsedok"withGOOGLE_GEMINI_BASE_URL=http://127.0.0.1:8787/bili/http://127.0.0.1:3425collapsedok, newpfa-*session inbili sessions ls(10.7 KiB, prefix-affinity)curlcollapsed form flips 403 → 200 on the same build. No launch-side shim or rewrite was used — agy's own collapsed URL now folds normally.