{"record":{"id":"61c1f4fadf80572f","repo":"crewAIInc/crewAI","slug":"file-does-not-exist-source-ref","errorCode":null,"errorMessage":"File does not exist: {source_ref}","messagePattern":"File does not exist: (.+?)","errorType":"exception","errorClass":"FileNotFoundError","httpStatus":null,"severity":"error","filePath":"lib/crewai-tools/src/crewai_tools/adapters/crewai_rag_adapter.py","lineNumber":208,"sourceCode":"            \".md\",\n        }\n\n        for arg in content_items:\n            source_ref: str\n            if isinstance(arg, dict):\n                source_ref = str(arg.get(\"source\", arg.get(\"content\", \"\")))\n            else:\n                source_ref = str(arg)\n\n            if not data_type:\n                ext = os.path.splitext(source_ref)[1].lower()\n                is_url = source_ref.startswith((\"http://\", \"https://\", \"file://\"))\n                if (\n                    ext in file_extensions\n                    and not is_url\n                    and not os.path.isfile(source_ref)\n                ):\n                    raise FileNotFoundError(f\"File does not exist: {source_ref}\")\n                data_type = DataTypes.from_content(source_ref)\n\n            if data_type == DataType.DIRECTORY:\n                if not os.path.isdir(source_ref):\n                    raise ValueError(f\"Directory does not exist: {source_ref}\")\n\n                # Define binary and non-text file extensions to skip\n                binary_extensions = {\n                    \".pyc\",\n                    \".pyo\",\n                    \".png\",\n                    \".jpg\",\n                    \".jpeg\",\n                    \".gif\",\n                    \".bmp\",\n                    \".ico\",\n                    \".svg\",\n                    \".webp\",","sourceCodeStart":190,"sourceCodeEnd":226,"githubUrl":"https://github.com/crewAIInc/crewAI/blob/754d7323beb2fd042e33444a115ea2d5a47193f0/lib/crewai-tools/src/crewai_tools/adapters/crewai_rag_adapter.py#L190-L226","documentation":"FileNotFoundError raised during auto-detection in the adapter's content-add path: the argument's extension is a known file type, it is not a URL scheme (http/https/file), and os.path.isfile says no such file exists. It protects against typos and wrong working directories before a loader is chosen.","triggerScenarios":"Passing 'docs/report.pdf' (or any known extension) as a positional arg or via path/file_path kwargs when the file is absent, relative to the process's current working directory rather than the caller's intent.","commonSituations":"Relative paths resolved from a different cwd (service started from another directory); file deleted or not yet written when the tool runs; path built with a missing prefix in env-specific config.","solutions":["Pass absolute paths: os.path.abspath(path) or Path(...).resolve() before calling the adapter.","Verify existence at the call site: assert Path(path).is_file().","For remote content, pass a full URL (http://...) so the URL branch is taken instead of the file check."],"exampleFix":"# before\nadapter(\"docs/report.pdf\")  # FileNotFoundError if cwd differs\n\n# after\nfrom pathlib import Path\np = Path(\"docs/report.pdf\").resolve()\nassert p.is_file(), f\"missing: {p}\"\nadapter(str(p))","handlingStrategy":"validation","validationCode":"from pathlib import Path\n\np = Path(source_ref)\nif not p.is_absolute():\n    p = p.resolve()\nif p.suffix.lower() in KNOWN_EXTENSIONS and not p.is_file():\n    raise FileNotFoundError(f\"missing input file: {p}\")\nadapter(str(p))","typeGuard":"def input_file_exists(source_ref: str) -> bool:\n    from pathlib import Path\n    p = Path(source_ref)\n    return p.is_file() or source_ref.startswith((\"http://\", \"https://\", \"file://\"))","tryCatchPattern":"try:\n    adapter(source_ref)\nexcept FileNotFoundError as e:\n    logger.error(\"missing input: %s\", e)\n    raise","preventionTips":["Always resolve paths to absolute form before passing them in.","Validate existence at the boundary (API handler) for user-supplied paths.","Use URLs explicitly for remote content."],"tags":["rag","file-not-found","path","auto-detect","crewai-tools"],"backgroundTag":null,"analyzedSha":"754d7323beb2fd042e33444a115ea2d5a47193f0","analyzedAt":"2026-08-15T04:06:56.746Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}