Reject query strings in `Client.base_url`

Closed
KL
18h ago
+32-2

Raise ValueError in BaseClient.base_url (used by both Client and AsyncClient on init and assignment) when base_url contains a query string, pointing callers to params=....

Previously _enforce_trailing_slash() and _merge_url() appended onto URL.raw_path (which includes ?query), silently producing malformed URLs such as https://example.com/api?key=k/items or dropping relative path segments when params= was passed. Checking b"?" in base_url.raw_path also catches trailing empty queries like https://example.com/api? while still allowing percent-encoded %3F in paths.

Closes #1236

Session: pi --session 01a24058-cc48-76fc-a013-84da8cb42ccf