`base_url` with a query string produces malformed request URLs
I maintainer di solito rispondono entro 1 giorno
@mohsinaliwork686-rgb ci sta già lavorando.
Dal 26/10/2026.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 52/100
Direzione di ricerca
Start in _client.py by reading _enforce_trailing_slash and _merge_url, focusing on their use of raw_path when base_url contains a query. Reproduce both examples, then confirm with maintainers whether query-bearing base URLs should be rejected or supported; done means tests cover both relative requests and params= without malformed or missing paths.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
A base_url that contains a query string is not rejected, but every relative request built from it has a broken URL. Reproduced on httpx2 2.13.1:
import httpx2
client = httpx2.Client(base_url="https://example.com/api?key=k")
print(repr(client.base_url))
# URL('https://example.com/api?key=k/')
print(client.build_request("GET", "items").url)
# https://example.com/api?key=k/items
print(client.build_request("GET", "items", params={"b": "2"}).url)
# https://example.com/api?b=2
In the first request the path ends up inside the query (key becomes k/items). In the second the path items is lost entirely. No error is raised in either case, so the request silently goes to the wrong URL.
Cause
Both steps operate on raw_path, which includes the query:
_enforce_trailing_slash(_client.py) appends/tourl.raw_path, so the slash lands after the query:/api?key=k/._merge_urlbuildsself.base_url.raw_path + merge_url.raw_path.lstrip(b"/"), so the request path is appended after the query too.
The second case then loses the path because params= replaces the whole query (#905), and the query now holds the path.
Possible fixes
- Reject a
base_urlwith a query string in thebase_urlsetter, with a message pointing toparams=. - Support it: operate on
pathrather thanraw_pathin both places and merge the base query into the request's params.
- Lingua principale
- Python
- Stelle
- 1.6k
- Fork
- 103
- Merge medio
- 1g 19h
- PR unite (30g)
- 25
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di pydantic/httpx2
-
Please revert aiter_bytes signature to AsyncIteratorForse di nuovo libera Una pull request per questa issue è stata chiusa senza essere unita. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
pydantic/httpx2#1158 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Export AutoBackendForse di nuovo libera Una pull request per questa issue è stata chiusa senza essere unita. Aperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 92/100
pydantic/httpx2#1131 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
I maintainer di solito rispondono entro 1 giorno
-
Mention header name error message for invalid header encodingsForse di nuovo libera Una pull request per questa issue è stata chiusa senza essere unita. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
pydantic/httpx2#864 · 3 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Support DigestAuth with "x-www-authenticate" in first response headerForse già presa Una pull request collegata a questa issue è aperta o già unita. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di pydantic/httpx2
Issue simili
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 85/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
OCA/account-invoicing#2529 ·
I maintainer di solito rispondono entro 1 giorno
-
area/ci
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 62/100
I maintainer di solito rispondono entro 1 giorno
-
ImageGen generate-batch aborts valid JSONL jobs containing a Unicode line separator in poster textApertabug imagen skills
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
Email validation accepts a trailing newlineForse già presa @marcello-pichini l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno