Skip to content

Append fetch query parameters before the URL fragment #88

Open

Description

@owenthcarey

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.selector includes the added parameters and excludes the fragment; assert the URL's fragment is preserved separately.
  • Empty or absent params leave 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.sh

Suggested 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

  1. added
    bug
    good first issue
    on Sep 10, 2026
  2. abhinandanjoshii commented on Sep 10, 2026

    @abhinandanjoshii

    hey @owenthcarey , can i pick this up ?

  3. owenthcarey commented on Sep 10, 2026

    @owenthcarey
    ContributorAuthor

    Definitely! Assigned to you. Thank you.

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

Metadata

Metadata

Labels

buggood first issue

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions