{"record":{"id":"ff965a44eb41f837","repo":"deepset-ai/haystack","slug":"unsupported-data-source-type-type-source-name","errorCode":null,"errorMessage":"Unsupported data source type: {type(source).__name__}","messagePattern":"Unsupported data source type: (.+?)","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"haystack/components/routers/file_type_router.py","lineNumber":176,"sourceCode":"\n        for source, meta_dict in zip(sources, meta_list, strict=True):\n            if isinstance(source, str):\n                source = Path(source)\n\n            if isinstance(source, Path):\n                if not source.exists():\n                    if self._raise_on_failure:\n                        raise FileNotFoundError(f\"File not found: {source}\")\n                    logger.warning(\"File not found: {source}. Skipping it.\", source=source)\n                    mime_types[\"failed\"].append(source)\n                    continue\n\n                mime_type = _guess_mime_type(source)\n\n            elif isinstance(source, ByteStream):\n                mime_type = source.mime_type\n            else:\n                raise TypeError(f\"Unsupported data source type: {type(source).__name__}\")\n\n            # If we have metadata, we convert the source to ByteStream and add the metadata\n            if meta_dict:\n                try:\n                    source = get_bytestream_from_source(source)\n                except Exception as e:\n                    if self._raise_on_failure:\n                        raise e\n                    logger.warning(\"Could not read {source}. Skipping it. Error: {error}\", source=source, error=e)\n                    mime_types[\"failed\"].append(source)\n                    continue\n\n                source.meta.update(meta_dict)\n\n            matched = False\n            if mime_type:\n                # Try exact equality first so MIMEs containing regex metacharacters (e.g. the `+` in\n                # `image/svg+xml`) match themselves before the regex fallback gets a chance to misread them.","sourceCodeStart":158,"sourceCodeEnd":194,"githubUrl":"https://github.com/deepset-ai/haystack/blob/e318778c9bf60a1963e3b5f451359655dd696c30/haystack/components/routers/file_type_router.py#L158-L194","documentation":"FileTypeRouter.run accepts only str, Path, and ByteStream sources; any other type raises this TypeError identifying the offending type name.","triggerScenarios":"run(sources=[b'bytes']) or run(sources=[{'path': 'f.pdf'}]) — passing raw bytes, dicts, or other objects instead of str/Path/ByteStream.","commonSituations":"Confusing raw file contents with file paths; passing Document objects from other Haystack components instead of ByteStream; integrating with code that yields different source types.","solutions":["Convert the source to a Path/str for file paths, or wrap bytes in ByteStream(data=..., mime_type=...)","Check the type reported in the message and adapt upstream code to yield supported types"],"exampleFix":"# before\nrouter.run(sources=[b\"raw pdf bytes\"])\n# after\nfrom haystack.dataclasses import ByteStream\nrouter.run(sources=[ByteStream(data=b\"raw pdf bytes\", mime_type=\"application/pdf\")])\n","handlingStrategy":"type-guard","validationCode":"from haystack.dataclasses import ByteStream\nfrom pathlib import Path\nbad = [s for s in sources if not isinstance(s, (str, Path, ByteStream))]","typeGuard":"def is_valid_source(source) -> bool:\n    from haystack.dataclasses import ByteStream\n    from pathlib import Path\n    return isinstance(source, (str, Path, ByteStream))","tryCatchPattern":"try:\n    result = router.run(sources=sources)\nexcept TypeError as e:\n    if \"Unsupported data source type\" in str(e):\n        sources = [s if is_valid_source(s) else ByteStream(data=bytes(s)) for s in sources]\n        result = router.run(sources=sources)\n    else:\n        raise","preventionTips":["Normalize all sources to str, Path, or ByteStream before run","Wrap raw bytes in ByteStream with an explicit mime_type","Narrow the type of upstream component outputs feeding sources"],"tags":["python","type-error","validation","router"],"backgroundTag":"unsupported-type","analyzedSha":"e318778c9bf60a1963e3b5f451359655dd696c30","analyzedAt":"2026-08-30T11:45:20.711Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}