{"record":{"id":"4ff290462a589705","repo":"unclecode/crawl4ai","slug":"context-files-not-found","errorCode":null,"errorMessage":"Context files not found","messagePattern":"Context files not found","errorType":"http","errorClass":"HTTPException","httpStatus":404,"severity":"warning","filePath":"deploy/docker/server.py","lineNumber":1040,"sourceCode":"\n    Parameters:\n    - context_type: Specify \"code\" for code context, \"doc\" for documentation context, or \"all\" for both.\n    - query: RECOMMENDED search query to filter paragraphs using BM25. You can leave this empty to get all the context.\n    - score_ratio: Minimum score as a fraction of the maximum score for filtering results.\n    - max_results: Maximum number of results to return. Default is 20.\n\n    Returns:\n    - JSON response with the requested context.\n    - If \"code\" is specified, returns the code context.\n    - If \"doc\" is specified, returns the documentation context.\n    - If \"all\" is specified, returns both code and documentation contexts.\n    \"\"\"\n    # load contexts\n    base = os.path.dirname(__file__)\n    code_path = os.path.join(base, \"c4ai-code-context.md\")\n    doc_path = os.path.join(base, \"c4ai-doc-context.md\")\n    if not os.path.exists(code_path) or not os.path.exists(doc_path):\n        raise HTTPException(404, \"Context files not found\")\n\n    with open(code_path, \"r\") as f:\n        code_content = f.read()\n    with open(doc_path, \"r\") as f:\n        doc_content = f.read()\n\n    # if no query, just return raw contexts\n    if not query:\n        if context_type == \"code\":\n            return JSONResponse({\"code_context\": code_content})\n        if context_type == \"doc\":\n            return JSONResponse({\"doc_context\": doc_content})\n        return JSONResponse({\n            \"code_context\": code_content,\n            \"doc_context\": doc_content,\n        })\n\n    tokens = query.split()","sourceCodeStart":1022,"sourceCodeEnd":1058,"githubUrl":"https://github.com/unclecode/crawl4ai/blob/7e801521428ee12509994d39151006f64055ebe3/deploy/docker/server.py#L1022-L1058","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"# before (Dockerfile)\nCOPY deploy/docker/server.py /app/server.py\n\n# after\nCOPY deploy/docker/server.py /app/server.py\nCOPY deploy/docker/c4ai-code-context.md deploy/docker/c4ai-doc-context.md /app/","handlingStrategy":"fallback","validationCode":"# only meaningful server-side; client can probe cheaply\nr = requests.get(f\"{S}/context\", params={\"type\": \"code\"}, timeout=10)\nif r.status_code == 404:\n    code_ctx = open(\"./c4ai-code-context.md\").read()  # local fallback copy","typeGuard":null,"tryCatchPattern":"try:\n    ctx = requests.get(f\"{S}/context\").json()\nexcept (requests.HTTPError, KeyError):\n    ctx = load_context_from_repo_checkout()  # vendored copy","preventionTips":["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"],"tags":["crawl4ai","docker","http-404","packaging","llm-context"],"backgroundTag":null,"analyzedSha":"7e801521428ee12509994d39151006f64055ebe3","analyzedAt":"2026-08-14T20:46:20.673Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}