unclecode/crawl4ai · warning · HTTPException
Context files not found
Error message
Context files not found
What it means
HTTP 404 from the context endpoint: the server serves LLM code/doc context from two markdown files (c4ai-code-context.md, c4ai-doc-context.md) expected next to server.py inside the container, and at least one is missing at request time.
Source
Thrown at deploy/docker/server.py:1040
Parameters:
- context_type: Specify "code" for code context, "doc" for documentation context, or "all" for both.
- query: RECOMMENDED search query to filter paragraphs using BM25. You can leave this empty to get all the context.
- score_ratio: Minimum score as a fraction of the maximum score for filtering results.
- max_results: Maximum number of results to return. Default is 20.
Returns:
- JSON response with the requested context.
- If "code" is specified, returns the code context.
- If "doc" is specified, returns the documentation context.
- If "all" is specified, returns both code and documentation contexts.
"""
# load contexts
base = os.path.dirname(__file__)
code_path = os.path.join(base, "c4ai-code-context.md")
doc_path = os.path.join(base, "c4ai-doc-context.md")
if not os.path.exists(code_path) or not os.path.exists(doc_path):
raise HTTPException(404, "Context files not found")
with open(code_path, "r") as f:
code_content = f.read()
with open(doc_path, "r") as f:
doc_content = f.read()
# if no query, just return raw contexts
if not query:
if context_type == "code":
return JSONResponse({"code_context": code_content})
if context_type == "doc":
return JSONResponse({"doc_context": doc_content})
return JSONResponse({
"code_context": code_content,
"doc_context": doc_content,
})
tokens = query.split()View on GitHub (pinned to 7e80152142)
Solutions
- docker exec <container> ls /app/c4ai-*.md to confirm which file is missing
- Rebuild from the official image (unclecode/crawl4ai) which ships both files, or add COPY c4ai-code-context.md c4ai-doc-context.md /app/ to your Dockerfile
- If you bind-mount the app dir, remove the mount or copy the two .md files into the mounted directory
- If you don't need the context endpoint, ignore the 404 - core crawling is unaffected
Example fix
# before (Dockerfile) COPY deploy/docker/server.py /app/server.py # after COPY deploy/docker/server.py /app/server.py COPY deploy/docker/c4ai-code-context.md deploy/docker/c4ai-doc-context.md /app/
Defensive patterns
Strategy: fallback
Validate before calling
# only meaningful server-side; client can probe cheaply
r = requests.get(f"{S}/context", params={"type": "code"}, timeout=10)
if r.status_code == 404:
code_ctx = open("./c4ai-code-context.md").read() # local fallback copy Try / catch
try:
ctx = requests.get(f"{S}/context").json()
except (requests.HTTPError, KeyError):
ctx = load_context_from_repo_checkout() # vendored copy Prevention
- Bake the two context .md files into any custom image and add a CI check that they exist
- Treat /context as optional: cache a local copy for offline LLM workflows
When it happens
Trigger: GET /context (or the code/doc/all variants) when the Docker image was built without copying the context markdown files, or a volume mount over /app hides them, or a source checkout is run outside Docker without generating them.
Common situations: Custom Dockerfile that copies only server.py and requirements; bind-mounting ./deploy/docker to /app from a clone where the .md files were never created; running the server from an sdist/k8s image that pruned docs files to shrink size.
Related errors
- Unsupported import format: {format}
- Invalid CSS selector , No elements found for CSS selector: {
- Invalid CSS selector: {css_selector}
- Invalid CSS selector, No elements found for CSS selector: {c
- This function must be run in Google Colab environment.
AI-assisted analysis of unclecode/crawl4ai@7e80152142 (2026-08-14).
Data as JSON: /api/errors/4ff290462a589705.
Report an issue: GitHub.