{"record":{"id":"e652563a12d285fd","repo":"crewAIInc/crewAI","slug":"directory-does-not-exist-source-ref","errorCode":null,"errorMessage":"Directory does not exist: {source_ref}","messagePattern":"Directory does not exist: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"lib/crewai-tools/src/crewai_tools/adapters/crewai_rag_adapter.py","lineNumber":213,"sourceCode":"            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\",\n                    \".pdf\",\n                    \".zip\",\n                    \".tar\",\n                    \".gz\",\n                    \".bz2\",","sourceCodeStart":195,"sourceCodeEnd":231,"githubUrl":"https://github.com/crewAIInc/crewAI/blob/754d7323beb2fd042e33444a115ea2d5a47193f0/lib/crewai-tools/src/crewai_tools/adapters/crewai_rag_adapter.py#L195-L231","documentation":"ValueError raised when the resolved data type is DataType.DIRECTORY but os.path.isdir is False for the source reference: the adapter was told (or auto-detected) the input is a directory, and that directory does not exist at the given path.","triggerScenarios":"Passing a directory path whose data_type resolves to directory (e.g. via auto-detection of a path with no file extension) while the directory is missing, renamed, or the path is relative to a different cwd.","commonSituations":"Knowledge-source directory moved or renamed after configuration; relative directory paths in services with unpredictable cwd; trailing characters/typos in configured paths.","solutions":["Use the absolute, resolved directory path and confirm it exists before ingestion.","Re-check configuration after moving a knowledge folder.","Validate at startup: for each configured source, assert os.path.isdir(source) or os.path.isfile(source)."],"exampleFix":"# before\nadapter(\"./knowledge/base\", data_type=\"directory\")  # ValueError if missing\n\n# after\nfrom pathlib import Path\nd = Path(\"./knowledge/base\").resolve()\nassert d.is_dir(), f\"missing dir: {d}\"\nadapter(str(d), data_type=DataType.DIRECTORY)","handlingStrategy":"validation","validationCode":"import os\n\nif data_type == DataType.DIRECTORY and not os.path.isdir(source_ref):\n    raise ValueError(f\"configured knowledge dir missing: {source_ref}\")\nadapter(source_ref, data_type=data_type)","typeGuard":"def directory_source_ok(source_ref: str) -> bool:\n    import os\n    return os.path.isdir(source_ref)","tryCatchPattern":"try:\n    adapter(source_ref, data_type=DataType.DIRECTORY)\nexcept ValueError as e:\n    if \"Directory does not exist\" in str(e):\n        logger.error(\"fix configured knowledge dir path\")\n    raise","preventionTips":["Resolve directory sources to absolute paths in configuration.","Add startup validation for every configured knowledge directory.","Re-verify paths after moving/renaming knowledge folders."],"tags":["rag","directory","path","validation","crewai-tools"],"backgroundTag":null,"analyzedSha":"754d7323beb2fd042e33444a115ea2d5a47193f0","analyzedAt":"2026-08-15T04:06:56.746Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}