Skip to content

fix: query parameters are lost when proxying requests in a sandbox router#371

Merged
k8s-ci-robot merged 5 commits into
kubernetes-sigs:mainfrom
xiaoj655:fix-router-missing-params
Apr 7, 2026
Merged

fix: query parameters are lost when proxying requests in a sandbox router#371
k8s-ci-robot merged 5 commits into
kubernetes-sigs:mainfrom
xiaoj655:fix-router-missing-params

Conversation

@xiaoj655

@xiaoj655 xiaoj655 commented Mar 6, 2026

Copy link
Copy Markdown
Contributor

The original implementation only forwarded the path, causing requests like /api/data?page=1&size=10 to arrive at the backend as /api/data, and the query parameters were lost.

@netlify

netlify Bot commented Mar 6, 2026

Copy link
Copy Markdown

Deploy Preview for agent-sandbox canceled.

Name Link
🔨 Latest commit 3130ccb
🔍 Latest deploy log https://app.netlify.com/projects/agent-sandbox/deploys/69d4a45212fc710008cb0650
@linux-foundation-easycla

linux-foundation-easycla Bot commented Mar 6, 2026

Copy link
Copy Markdown

CLA Signed

The committers listed above are authorized under a signed CLA.

@k8s-ci-robot

Copy link
Copy Markdown
Contributor

Welcome @xiaoj655!

It looks like this is your first PR to kubernetes-sigs/agent-sandbox 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes-sigs/agent-sandbox has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot

Copy link
Copy Markdown
Contributor

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 /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work.

Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions 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.

@k8s-ci-robot k8s-ci-robot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Mar 6, 2026

@natasha41575 natasha41575 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change looks good, but I wonder if we can add a unit test for coverage?

@natasha41575

Copy link
Copy Markdown

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Mar 9, 2026
@xiaoj655 xiaoj655 force-pushed the fix-router-missing-params branch from 170d6da to fa96d5d Compare March 10, 2026 03:15
@xiaoj655

xiaoj655 commented Mar 10, 2026

Copy link
Copy Markdown
Contributor Author

Change looks good, but I wonder if we can add a unit test for coverage?

@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.

@natasha41575

Copy link
Copy Markdown

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Mar 11, 2026
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Mar 12, 2026
@xiaoj655 xiaoj655 requested a review from natasha41575 March 12, 2026 02:24
@xiaoj655

Copy link
Copy Markdown
Contributor Author

@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 codebot-robot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

@SHRUTI6991

Copy link
Copy Markdown
Contributor

@xiaoj655 can you please address the codebot comment?

Otherwise it looks good to me too. I can approve once the codebot comment is addressed.

Copilot AI review requested due to automatic review settings April 7, 2026 03:37
@k8s-ci-robot k8s-ci-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Apr 7, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 httpx request.

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.

@xiaoj655

xiaoj655 commented Apr 7, 2026

Copy link
Copy Markdown
Contributor Author

@xiaoj655 can you please address the codebot comment?

Otherwise it looks good to me too. I can approve once the codebot comment is addressed.

HI, I have resolve the codebot comment.

  • simplify code using URL.replace
  • simplify test case

@xiaoj655 xiaoj655 left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

@xiaoj655

xiaoj655 commented Apr 7, 2026

Copy link
Copy Markdown
Contributor Author

/assign @SHRUTI6991

@SHRUTI6991

Copy link
Copy Markdown
Contributor

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Apr 7, 2026
@k8s-ci-robot

Copy link
Copy Markdown
Contributor

[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

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Apr 7, 2026
@k8s-ci-robot k8s-ci-robot merged commit 4b57438 into kubernetes-sigs:main Apr 7, 2026
9 checks passed
khirotaka pushed a commit to khirotaka/agent-sandbox that referenced this pull request Jun 12, 2026
…uter (kubernetes-sigs#371)

* fix: preserve query string when proxying requests in sandbox router

* test: add unit test

* chore

* trigger ci
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. area:rich-client cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.

7 participants