[Bug]: Failed CrawlResult has `links: {}` / `media: {}` instead of the usual keys
I maintainer di solito rispondono entro 1 giorno
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 78/100
Direzione di ricerca
Start with CrawlResult defaults in crawl4ai/models.py and the result construction branches in crawl4ai/async_webcrawler.py, especially robots.txt refusal, proxy failure, exception, and anti-bot fallback paths. Reproduce the two-URL /crawl case with check_robots_txt=true, then verify that failed and fallback results expose the same internal/external link and image/video/audio media keys as successful results.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
crawl4ai version
0.9.4 (also on 0.9.2)
Expected Behavior
A result that failed (robots.txt refusal, fetch error, "All proxies failed") has the same links and media keys as a successful one:
"links": {"internal": [], "external": []},
"media": {"images": [], "videos": [], "audios": []}
so a client can read links["internal"] without special-casing failures.
Current Behavior
CrawlResult.links and CrawlResult.media default to {} (models.py#L136-L137). Successful crawls fill them from the scraper's typed Links / Media models, but the results AsyncWebCrawler.arun builds itself never set them:
- robots.txt refusal (async_webcrawler.py#L385-L397)
- "All proxies failed" (#L640-L646)
- the exception path (#L710-L712)
- the anti-bot raw-HTML fallback, which is a successful result (#L588-L598)
So in a mixed batch /crawl returns "links": {}, "media": {} for exactly the entries a client has to handle differently, and in the SDK result.links["internal"] raises KeyError. Since #2134 keeps failed results in /crawl responses, every batch with a refused or failed URL has this shape. In one client that read links.internal.length, the resulting TypeError was taken for a failed request and the healthy pages of the batch were re-crawled several times over.
cc @nightcityblade (#2134) @ntohidi
Is this reproducible?
Yes
Inputs Causing the Bug
- Two URLs on one site, one of them disallowed by its robots.txt
- crawler_config params: {"check_robots_txt": true}
Steps to Reproduce
1. Run the Docker image (0.9.4, or built from develop)
2. POST /crawl with both URLs and check_robots_txt=true
3. Compare `links` / `media` of the two results
Code snippets
from crawl4ai.models import CrawlResult
# What AsyncWebCrawler.arun returns for a URL robots.txt disallows
r = CrawlResult(url="https://example.com/private", html="", success=False,
status_code=403, error_message="Access denied by robots.txt")
print(r.links, r.media) # {} {}
r.links["internal"] # KeyError: 'internal'
OS
Linux (Docker image built from develop @ 1f68e5b)
Python version
3.12 (the image's)
Browser
Chromium (Playwright, bundled)
Browser version
No response
Error logs & Screenshots (if applicable)
POST /crawl, check_robots_txt=true, two URLs of a local test site (CRAWL4AI_ALLOW_INTERNAL_URLS=true), /private disallowed by its robots.txt:
[shape] HTTP 200
/index.html success=True status=200 links=['external', 'internal'] media=['audios', 'images', 'videos'] error=''
/private/index.html success=False status=403 links={} media={} error='Access denied by robots.txt'
- Lingua principale
- Python
- Stelle
- 84.8k
- Fork
- 8.8k
- Merge medio
- 14h 10m
- PR unite (30g)
- 12
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
-
[Bug]: whitespace-only inline elements are removed from cleaned_html, merging words in raw_markdown (prose, not only <pre>/<code>)Forse già presa @drakeo338 l’ha presa 9 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 83/100
I maintainer di solito rispondono entro 1 giorno
-
[Bug]: HTTP crawler puts proxy credentials into the URL unencodedForse già presa @omarbounawarapy l’ha presa 10 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
unclecode/crawl4ai#2326 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
[Bug]: Same PDF gives different markdown on each run when batch_size > 1 (threads share current_page_number)Forse già presa @Kylinny l’ha presa 11 giorni fa. Aperta🐞 Bug 🩺 Needs Triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
unclecode/crawl4ai#2319 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
[Bug]: Reusing BFSDeepCrawlStrategy leaks the previous crawl's max_pages budget into a fresh runForse già presa @nightcityblade l’ha presa 12 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
unclecode/crawl4ai#2309 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
[Bug]: Docker server fails to boot after mcp 2.0.0 release — mcp_bridge uses the removed v1 low-level APIForse di nuovo libera @nightcityblade l’ha presa 52 giorni fa e non c’è nessuna pull request aperta. Aperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 84/100
unclecode/crawl4ai#2147 · 5 commenti ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di unclecode/crawl4ai
Issue simili
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 82/100
esphome/esphome.io#7657 ·
I maintainer di solito rispondono entro 1 giorno
-
comp/gateway comp/plugins duplicate P3 type/bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
NousResearch/hermes-agent#137019 ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
Kumo-Tabular weights unreachable behind restrictive egress proxies (Xet + plain HTTP both fail)Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 67/100
NVIDIA/structured-data-models#1091 ·
I maintainer di solito rispondono entro 1 giorno
-
[work-item] adam-adae-worsening-emergence: conform spec.yaml to the specification style contract (REQ-1280)Forse già presa @muse-yamaa-bot l’ha presa oggi. Apertawork-item
Difficoltà 1/5 1-3 ore Idoneità per principianti 82/100
I maintainer di solito rispondono entro 1 giorno