Skip to content

fix: preserve base URL query components in requests - #213

Draft
Kayvan-Zahiri wants to merge 1 commit into
trycourier:mainfrom
Kayvan-Zahiri:codex/base-url-query-components
Draft

Kayvan-Zahiri wants to merge 1 commit into
trycourier:mainfrom
Kayvan-Zahiri:codex/base-url-query-components

Conversation

@Kayvan-Zahiri

Copy link
Copy Markdown

Problem

A custom base URL such as https://gateway.example/gateway?workspace=demo produces /gateway/?workspace=demo/messages/message-id when retrieving a message. The endpoint becomes part of the query, so gateway deployments request the wrong resource. The trailing-slash helper also appends / to the query value because HTTPX raw_path includes the query string.

Change

Separate raw path and query components when normalizing and joining URLs. Preserve percent-encoded paths, base and endpoint queries, and fragments. Absolute endpoint URLs remain independent of the client's base URL.

Add 16 sync/async public-client transport regressions, including normal message retrieval and query/absolute URL controls. The first 12 cases run on the original code: 8 fail, 4 pass. No hosted API or credentials are used.

Validation

  • Python 3.12 offline suite: 490 passed, 2 skipped.
  • Python 3.9 offline suite: 492 passed.
  • Python 3.9 / Pydantic 1: 479 passed, 13 skipped.
  • Ruff, Pyright (source, tests, noxfile) and Python 3.9 Mypy pass; wheel/sdist build.
  • API-resource contract tests requiring a local Prism server were excluded.

Environment notes: the development lock has mutually incompatible filelock/virtualenv pins. Python 3.12 used an environment-only filelock override; Python 3.9 used virtualenv20.34.0. Repository dependency files are unchanged. Locked Mypy on Python3.12 also reports an existing typing.TypeAliasType incompatibility in untouched _typing.py; the repository's Python3.9 target passes Mypy.

The core module is generator-managed; CONTRIBUTING.md permits persisted manual changes. Maintainers may wish to propagate this fix to the generator as well.

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

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant