fix: query parameters are lost when proxying requests in a sandbox router#371
Conversation
✅ Deploy Preview for agent-sandbox canceled.
|
|
Welcome @xiaoj655! |
|
Hi @xiaoj655. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Regular contributors should join the org to skip this step. Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
natasha41575
left a comment
There was a problem hiding this comment.
Change looks good, but I wonder if we can add a unit test for coverage?
|
/ok-to-test |
170d6da to
fa96d5d
Compare
@natasha41575 Thanks for the suggestion! I've added test_sandbox_router.py with parametrized tests covering all HTTP methods × multiple query string variants. The tests mock the internal httpx client and verify the forwarded URL preserves the query string correctly. |
|
/lgtm |
|
@natasha41575 @janetkuo Hi, just a gentle ping. This PR fixes 'query parameters are lost' issue, would appreciate a review when you have time. |
codebot-robot
left a comment
There was a problem hiding this comment.
Overall, this PR implements a solid fix for the reported bug by correctly forwarding query parameters in the sandbox router. The choice to use the raw request.url.query string properly preserves duplicate keys, preventing the unexpected dropping of parameters. Additionally, the accompanying parameterized tests ensure good coverage across various HTTP methods and query shapes.
There are a few minor suggestions for improvement. On the implementation side, using Starlette's URL.replace could simplify how the proxy URL is constructed, and there are some nuances regarding path decoding in FastAPI proxies to keep in mind. For the tests, improving semantics (e.g., swapping xfail for an explicit path assertion) and clarifying how the test mock handles the httpx.Request object will help prevent future confusion.
(This review was generated by Overseer)
|
@xiaoj655 can you please address the codebot comment? Otherwise it looks good to me too. I can approve once the codebot comment is addressed. |
There was a problem hiding this comment.
Pull request overview
Fixes the sandbox-router’s request proxying so that query strings are preserved when forwarding requests to the target sandbox service (e.g., /api/data?page=1 no longer arrives as /api/data).
Changes:
- Update proxy target URL construction to derive from
request.url(preserving query parameters) while replacing scheme/host/port for the in-cluster sandbox destination. - Add a regression test ensuring query parameters are forwarded into the proxied
httpxrequest.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
clients/python/agentic-sandbox-client/sandbox-router/sandbox_router.py |
Builds the proxied URL via request.url.replace(...) so the original query string is retained. |
clients/python/agentic-sandbox-client/sandbox-router/test_sandbox_router.py |
Adds a test that captures the built httpx request URL params and asserts they match the incoming query string. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
HI, I have resolve the codebot comment.
|
|
/assign @SHRUTI6991 |
|
/lgtm |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: SHRUTI6991, xiaoj655 The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
…uter (kubernetes-sigs#371) * fix: preserve query string when proxying requests in sandbox router * test: add unit test * chore * trigger ci
The original implementation only forwarded the path, causing requests like
/api/data?page=1&size=10to arrive at the backend as/api/data, and the query parameters were lost.