Repository navigation
Description
Problem
_build_request() in src/pythonnative/net.py appends encoded params to the end of the entire URL. If the URL contains a fragment, the new parameters become part of that fragment and aren't sent to the server.
Confirmed example:
url: https://example.test/items?existing=1#details
params: {"q": "hello world"}
current: https://example.test/items?existing=1#details&q=hello+world
expected: https://example.test/items?existing=1&q=hello+world#details
The current request's selector is /items?existing=1, so the server never receives q.
Requested change
Use urllib.parse.urlsplit() and urlunsplit() to append to the query component while preserving the fragment. Keep urlencode(..., doseq=True) so list-valued parameters continue to work.
Acceptance criteria
- Tests cover URLs with neither query nor fragment, an existing query, a fragment, and both.
- Existing query parameters remain intact, including repeated keys and encoded values.
- List-valued parameters still become repeated query parameters.
- Assert the outgoing
Request.selectorincludes the added parameters and excludes the fragment; assert the URL's fragment is preserved separately. - Empty or absent
paramsleave the URL unchanged.
Starting points and verification
Add focused request-construction tests in tests/test_net.py; these cases don't need a server or network. Keep this change focused on URL assembly so it can be reviewed independently of request header handling.
uv run pytest tests/test_net.py -q
./scripts/check.shSuggested commit message
Following CONTRIBUTING.md:
fix(net): append query parameters before URL fragments
Before starting
Please follow the issue-claiming process: check for an assignee or linked pull request, comment to claim the issue, and wait for a maintainer to assign it before opening a pull request. Contributor setup is in CONTRIBUTING.md.
Activity
abhinandanjoshii commentedon Sep 10, 2026
hey @owenthcarey , can i pick this up ?
owenthcarey commentedon Sep 10, 2026
Definitely! Assigned to you. Thank you.