Skip to content

[Bug]: /crawl returns HTTP 500 when wait_for selector never matches (Docker 0.9.2) #2133

Description

@per1970

Version: 0.9.2 (Docker, unclecode/crawl4ai:0.9.2, tag digest verified current)

What happens

POST /crawl with crawler_config.wait_for set to a CSS selector that never matches the page returns an opaque HTTP 500 instead of a per-URL error result:

{"error": "Internal server error", "correlation_id": "..."}

Repro

curl -s -X POST http://localhost:8090/crawl \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer <token>' \
  -d '{"urls":["https://www.reddit.com/r/selfhosted/"],"crawler_config":{"wait_until":"networkidle","wait_for":"css:.quote"}}'

(.quote exists on quotes.toscrape.com, not on Reddit.)

Results (all against the same 0.9.2 container):

URL wait_for Result
quotes.toscrape.com/js/ css:.quote (matches) HTTP 200, content OK
www.reddit.com/r/selfhosted/ css:.quote (no match) HTTP 500, opaque error
api-docs.deepseek.com css:article (no match at check time) HTTP 500, opaque error
www.reddit.com/r/selfhosted/ css:shreddit-post (matches) HTTP 200, content OK

So this is a crash on an unmatched selector, not a general wait_for failure.

Related observations on the same endpoint (0.9.2)

  • Bad wait_until enum value (e.g. "not-a-real-value") → HTTP 500, not a 422 validation error.
  • Unknown fields inside crawler_config (e.g. bogus_param_xyz) → silently ignored (HTTP 200); the schema accepts arbitrary keys without complaint.

Root-cause hypothesis

Same symptom family as #2116 / #2117 — the Docker API promotes unsuccessful crawls to HTTP 500 and _http_exception_handler swallows the detail. #2117 addresses that for the single-URL /md and /llm/{url} handlers; /crawl appears to have the same failure mode but is not covered. Note: the 500s return within a few seconds, which looks like an immediate exception when the selector never appears rather than a page_timeout wait — worth confirming whether it is the same if not result.success: raise HTTPException(500) path or a separate crash in the wait_for handling.

Expected behavior

An unmatched wait_for should surface as a per-URL error result (or a 4xx with the reason preserved), not a generic 500 — the same treatment PR #2117 proposes for the single-URL handlers.


Investigation and repro produced with AI assistance (automated agent); reviewed and filed by a human.

Metadata

Metadata

Assignees

No one assigned

    Labels

    ⚙ DoneBug fix, enhancement, FR that's completed pending release🐞 BugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions