Bug]: Crawl4aiDockerClient gets 400 with any BrowserConfig: dump() always sends the generated `headers`
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 72/100
Direzione di ricerca
Inizia leggendo BrowserConfig.dump() e l’inizializzazione descritta di BrowserConfig che genera sec-ch-ua; poi verifica la riproduzione del caricamento non attendibile nell’issue. Verifica che la configurazione serializzata non invii più il campo headers generato e che una richiesta con BrowserConfig() venga accettata dal server.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
crawl4ai version
0.9.5 (also on develop; since 0.9.0)
Expected Behavior
Crawl4aiDockerClient.crawl(..., browser_config=BrowserConfig(headless=True)) is accepted by the server. The user did not set any headers.
Current Behavior
Every request with a BrowserConfig is rejected:
400 Rejected request: field 'headers' is not permitted on BrowserConfig from an untrusted request
BrowserConfig.__init__ always adds a sec-ch-ua header derived from the user agent:
self.browser_hint = UAGen.generate_client_hints(self.user_agent)
self.headers.setdefault("sec-ch-ua", self.browser_hint)
So headers is never empty, and dump() always writes it. The server forbids headers from an untrusted request (UNTRUSTED_FORBIDDEN_FIELDS["BrowserConfig"]) and rejects it whatever its value. The client sends browser_config.dump(), so it fails with any BrowserConfig, even BrowserConfig(). Without a BrowserConfig the request works.
The server rule is right. The problem is that dump() sends a header the user never set, and the server's __init__ derives the same value again from user_agent anyway.
#2262 hit the same 400 in the playground and worked around it there by forwarding only the typed params. The client was not fixed.
Is this reproducible?
Yes
Inputs Causing the Bug
Any BrowserConfig passed to Crawl4aiDockerClient, or any BrowserConfig(...).dump() posted to /crawl, /crawl/stream or /crawl/job.
Steps to Reproduce
Run the snippet below; it reproduces the server's check in-process. Against a running server, Crawl4aiDockerClient().crawl(["https://example.com"], browser_config=BrowserConfig()) returns the same 400.
Code snippets
from crawl4ai import BrowserConfig
from crawl4ai.async_configs import Provenance
data = BrowserConfig(headless=True).dump()
print(data["params"]["headers"])
# {'type': 'dict', 'value': {'sec-ch-ua': '"Chromium";v="116", "Not_A Brand";v="8", "Google Chrome";v="116"'}}
BrowserConfig.load(data, provenance=Provenance.UNTRUSTED)
# UntrustedConfigError: field 'headers' is not permitted on BrowserConfig from an untrusted request
OS
macOS 26.6 (platform-independent)
Python version
3.13
Browser
Not involved
Error logs & Screenshots (if applicable)
See above. I'll open a PR.
- Lingua principale
- Python
- Stelle
- 86.8k
- Fork
- 9k
- Merge medio
- 2g 12h
- PR unite (30g)
- 21
Preparare l'ambiente
- Include un Dockerfile o un 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 unclecode/crawl4ai
-
[Feature]: Crawl4aiDockerClient has no public option for the API token the 0.9 server requiresAperta⚙ Done ✨ Enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 77/100
I maintainer di solito rispondono entro 1 giorno
-
[Bug]: PDF images saved with save_images_locally=True come back with an empty src in result.mediaAperta🐞 Bug 🩺 Needs Triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
🐞 Bug 🩺 Needs Triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
unclecode/crawl4ai#2416 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
⚙ Done 🐞 Bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
unclecode/crawl4ai#2382 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
⚙ Done 🐞 Bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
unclecode/crawl4ai#2381 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di unclecode/crawl4ai
Issue simili
-
Difficoltà 1/5 1-3 ore Idoneità per principianti 78/100
QuantConnect/Documentation#2838 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
awslabs/route53-dynamic-dns-with-lambda#67 · 1 commento ·
-
`SubAgents` returns a child run's `DeferredToolRequests` to the parent as a successful tool resultApertabug pkg:harness
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
pydantic/pydantic-ai#12405 ·
I maintainer di solito rispondono entro 1 giorno
-
good first issue help wanted
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
-
good first issue help wanted
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 82/100