Repository navigation
fix(proxy): route on pathname so query strings match - #85
robertn702 wants to merge 1 commit into
Conversation
request.url includes the query string, so exact matches missed every route when one was present (Codex appends ?client_version= to GET /v1/models). Match on the path before '?' instead. Decision: split on '?' rather than new URL(...).pathname, which would also normalize absolute-form targets and route 'POST http://attacker.example/v1/responses' instead of the existing 404. The query string is still not forwarded upstream. Fixes #84
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Query-free route matching packages/proxy/src/server.ts, packages/proxy/test/server.test.ts, .changeset/proxy-route-query-string.md |
The proxy uses the query-free path for draining exemptions, route eligibility, and handling health, readiness, models, responses, and configured messages routes. Tests check route responses, query-free upstream paths, and the existing 404 response for unknown paths. A patch changeset records the change. |
Priority:
Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Bug fix · Severity of issue fixed: Medium
Merge Risk: 
Minimal · up to 8f713
-
Known routes can match requests with query strings, and no actionable merge-blocking risk is identified.
Pre-merge checks: 
4 · 
1
-
Failed checks: 1 warning Passed checks: 4 passed-
Full details: Linked Issues check
-
Explanation
Issue
#84requires known routes to work when the request includes a query string.packages/proxy/src/server.tsdefinesrequestPathby removing the query portion and uses it for health, readiness, models, responses, messages, draining, and in-flight routing checks. The newquery stringstests cover the required routes and preserve the unknown-route 404 response. The tests also verify that upstream receives/models,/responses, and/messageswithout the query string.
Full details: Out of Scope Changes check
-
Explanation
The reviewed changes stay within issue
#84. The implementation changes route-path handling, preserves absolute-form target behavior, and keeps query strings out of upstream requests. The added tests verify the required behavior. The proxy patch changeset supports the implementation release.
-
Full details: Docstring Coverage
-
Explanation
Docstring coverage is 0.00% 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. (1 skipped: 1 unsupported.)
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
-
Finishing Touches: 💡 1
-
📝 Generate docstrings: 💡
-
- Commit to this branch
- Create a new PR
🧪 Generate unit tests (beta)
-
- Commit to this branch
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
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.
Comment @coderabbitai help to get the list of available commands.
|
Superseded by #86, which implements the same path-based route matching and is now merged into |
What this fixes
#84:
GET /v1/modelsreturns 404 when a query string is present. Codex adds?client_version=<version>when it refreshes its model catalog, so every refresh through the proxy failed./health,/ready,/v1/responses, and/v1/messagesused the same exact match onrequest.urland failed the same way.What changed
packages/proxy/src/server.tsrequestPath(request): returnsrequest.urlup to the first?.createAppServer: the draining exemption (/health,/ready) and theproxiedin-flight check now compare againstrequestPath.handle: every route match and the/v1/messagesprovider choice now compare againstrequestPath. Method checks and the{"error":"not_found","message":"unknown route"}404 are unchanged.packages/proxy/test/server.test.ts: newquery stringssuite./health,/ready, and/v1/modelswith?client_version=1return the same status and body as without it, andPOST /v1/responses?...andPOST /v1/messages?...reach the upstream..changeset/proxy-route-query-string.md: patch bump for@reasoning-router/proxy.Decision: split on
?instead ofnew URL(...).pathnamenew URL(request.url, base).pathnamewould also normalize absolute-form request targets, soPOST http://attacker.example:<port>/v1/responseswould start matching a route. Today it returns 404, and an existing Host-validation test checks that. Splitting on?fixes the bug and leaves that behavior alone. The query string is still not forwarded upstream (the same as before for the bare path).Verification
npm run check: typecheck and lint pass (1 Biome warning, also onmain). Vitest: 36 files, 478 tests passed.server.tsand passes with the fix.node packages/proxy/dist/index.json port 4392 against a stub upstream on 4391, with a bearer dummy key.Before (old
server.ts):After:
Fixes #84
Summary by CodeRabbit