{"record":{"id":"4380aa511abf1637","repo":"crewAIInc/crewAI","slug":"error-loading-chunker-for-self-e","errorCode":null,"errorMessage":"Error loading chunker for {self}: {e}","messagePattern":"Error loading chunker for (.+?): (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"lib/crewai-tools/src/crewai_tools/rag/data_types.py","lineNumber":62,"sourceCode":"            DataType.DIRECTORY: (\"text_chunker\", \"TextChunker\"),\n            DataType.YOUTUBE_VIDEO: (\"text_chunker\", \"TextChunker\"),\n            DataType.YOUTUBE_CHANNEL: (\"text_chunker\", \"TextChunker\"),\n            DataType.GITHUB: (\"text_chunker\", \"TextChunker\"),\n            DataType.DOCS_SITE: (\"text_chunker\", \"TextChunker\"),\n            DataType.MYSQL: (\"text_chunker\", \"TextChunker\"),\n            DataType.POSTGRES: (\"text_chunker\", \"TextChunker\"),\n        }\n\n        if self not in chunkers:\n            raise ValueError(f\"No chunker defined for {self}\")\n        module_name, class_name = chunkers[self]\n        module_path = f\"crewai_tools.rag.chunkers.{module_name}\"\n\n        try:\n            module = import_module(module_path)\n            return cast(BaseChunker, getattr(module, class_name)())\n        except Exception as e:\n            raise ValueError(f\"Error loading chunker for {self}: {e}\") from e\n\n    def get_loader(self) -> BaseLoader:\n        loaders = {\n            DataType.PDF_FILE: (\"pdf_loader\", \"PDFLoader\"),\n            DataType.TEXT_FILE: (\"text_loader\", \"TextFileLoader\"),\n            DataType.TEXT: (\"text_loader\", \"TextLoader\"),\n            DataType.XML: (\"xml_loader\", \"XMLLoader\"),\n            DataType.WEBSITE: (\"webpage_loader\", \"WebPageLoader\"),\n            DataType.MDX: (\"mdx_loader\", \"MDXLoader\"),\n            DataType.JSON: (\"json_loader\", \"JSONLoader\"),\n            DataType.DOCX: (\"docx_loader\", \"DOCXLoader\"),\n            DataType.CSV: (\"csv_loader\", \"CSVLoader\"),\n            DataType.DIRECTORY: (\"directory_loader\", \"DirectoryLoader\"),\n            DataType.YOUTUBE_VIDEO: (\"youtube_video_loader\", \"YoutubeVideoLoader\"),\n            DataType.YOUTUBE_CHANNEL: (\n                \"youtube_channel_loader\",\n                \"YoutubeChannelLoader\",\n            ),","sourceCodeStart":44,"sourceCodeEnd":80,"githubUrl":"https://github.com/crewAIInc/crewAI/blob/754d7323beb2fd042e33444a115ea2d5a47193f0/lib/crewai-tools/src/crewai_tools/rag/data_types.py#L44-L80","documentation":"get_chunker() dynamically imports crewai_tools.rag.chunkers.<module> and instantiates <Class>; any exception during import or construction (missing optional dependency like langchain_text_splitters, ImportError inside the chunker module, TypeError from constructor args) is wrapped as ValueError('Error loading chunker for <DataType>: <cause>'). The root cause is in the chained exception.","triggerScenarios":"A chunker module importing an optional heavy dependency that is not installed (e.g. a website/youtube chunker needing extra packages); a broken install where a chunker submodule is missing; constructor raising because of a missing third-party lib.","commonSituations":"Slim installs of crewai-tools without rag extras; partial/failed pip installs; upgrading crewai-tools where chunker module deps changed.","solutions":["Inspect e.__cause__ to see the underlying import/construction error","Install the missing optional dependency it names (e.g. uv add <package>)","Reinstall crewai-tools cleanly if modules are missing: uv sync / pip install --force-reinstall crewai-tools","Pin a known-good crewai-tools version"],"exampleFix":"# before\ntry:\n    chunker = dtype.get_chunker()\nexcept ValueError as e:\n    raise\n# after\ntry:\n    chunker = dtype.get_chunker()\nexcept ValueError as e:\n    logger.error('chunker load failed: %s', e.__cause__)\n    # e.g. cause says ModuleNotFoundError: install the named package\n    raise","handlingStrategy":"try-catch","validationCode":"try:\n    from crewai_tools.rag.chunkers.text_chunker import TextChunker  # noqa: F401\nexcept ImportError as e:\n    raise SystemExit(f'missing chunker dependency: {e}')","typeGuard":null,"tryCatchPattern":"try:\n    chunker = dtype.get_chunker()\nexcept ValueError as e:\n    cause = str(e.__cause__ or '')\n    if 'No module named' in cause:\n        raise SystemExit(f'install missing dependency: {cause}') from e\n    raise","preventionTips":["Pre-import the chunkers your pipeline uses at startup to surface dependency gaps","Install rag optional extras alongside crewai-tools","Log the chained cause, not just the wrapper ValueError"],"tags":["rag","chunking","dependency","dynamic-import"],"backgroundTag":null,"analyzedSha":"754d7323beb2fd042e33444a115ea2d5a47193f0","analyzedAt":"2026-08-15T04:06:56.746Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}