{"record":{"id":"5488981f47cff930","repo":"deepset-ai/haystack","slug":"unsupported-source-type-type-source","errorCode":null,"errorMessage":"Unsupported source type {type(source)}","messagePattern":"Unsupported source type (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"haystack/components/converters/utils.py","lineNumber":56,"sourceCode":"def get_bytestream_from_source(source: str | Path | ByteStream, guess_mime_type: bool = False) -> ByteStream:\n    \"\"\"\n    Creates a ByteStream object from a source.\n\n    :param source:\n        A source to convert to a ByteStream. Can be a string (path to a file), a Path object, or a ByteStream.\n    :param guess_mime_type:\n        Whether to guess the mime type from the file.\n    :return:\n        A ByteStream object.\n    \"\"\"\n\n    if isinstance(source, ByteStream):\n        return source\n    if isinstance(source, (str, Path)):\n        bs = ByteStream.from_file_path(Path(source), guess_mime_type=guess_mime_type)\n        bs.meta[\"file_path\"] = str(source)\n        return bs\n    raise ValueError(f\"Unsupported source type {type(source)}\")\n\n\ndef normalize_metadata(meta: dict[str, Any] | list[dict[str, Any]] | None, sources_count: int) -> list[dict[str, Any]]:\n    \"\"\"\n    Normalize the metadata input for a converter.\n\n    Given all the possible value of the meta input for a converter (None, dictionary or list of dicts),\n    makes sure to return a list of dictionaries of the correct length for the converter to use.\n\n    :param meta: the meta input of the converter, as-is\n    :param sources_count: the number of sources the converter received\n    :returns: a list of dictionaries of the make length as the sources list\n\n    Each source always gets its own independent dictionary. When ``meta`` is ``None`` or a single\n    dictionary, a separate copy is returned for every source so that mutating one source's metadata\n    downstream does not leak into the others.\n    \"\"\"\n    if meta is None:","sourceCodeStart":38,"sourceCodeEnd":74,"githubUrl":"https://github.com/deepset-ai/haystack/blob/e318778c9bf60a1963e3b5f451359655dd696c30/haystack/components/converters/utils.py#L38-L74","documentation":"get_bytestream_from_source normalizes converter sources into a ByteStream. It accepts an existing ByteStream, or a str/Path file path; anything else raises ValueError. This validates the `sources` input of HTMLToDocument-family converters before file loading.","triggerScenarios":"Calling get_bytestream_from_source (or a converter's run(sources=...)) with an unsupported object such as a URL string, an open file handle, bytes, or a Document, rather than a ByteStream, str path, or Path.","commonSituations":"Passing a URL expecting the converter to download it; passing a file-like object from open(); passing raw bytes; upstream pipeline component emitting Documents instead of paths/ByteStreams.","solutions":["Convert the input first: use ByteStream.from_file_path(Path(source)) for local files or ByteStream(data=...) for in-memory bytes.","For URLs, download with a fetcher component (e.g. LinkContentFetcher) before the converter.","Ensure upstream components emit file paths or ByteStreams, not Documents or file handles."],"exampleFix":"# before\nconverter.run(sources=[\"https://example.com/page.html\"])  # ValueError\n# after\nfrom haystack.dataclasses import ByteStream\nimport requests\ndata = requests.get(\"https://example.com/page.html\").content\nconverter.run(sources=[ByteStream(data=data, meta={\"url\": \"https://example.com/page.html\"})])","handlingStrategy":"type-guard","validationCode":"from pathlib import Path\nfrom haystack.dataclasses import ByteStream\n\ndef is_valid_source(s) -> bool:\n    return isinstance(s, (ByteStream, str, Path))\n\nbad = [s for s in sources if not is_valid_source(s)]\nif bad:\n    raise TypeError(f\"Convert ByteStream/str/Path required, got: {[type(s) for s in bad]}\")","typeGuard":"from pathlib import Path\nfrom haystack.dataclasses import ByteStream\n\ndef as_source(s: object) -> ByteStream:\n    if isinstance(s, ByteStream):\n        return s\n    if isinstance(s, (str, Path)):\n        bs = ByteStream.from_file_path(Path(s))\n        bs.meta[\"file_path\"] = str(s)\n        return bs\n    raise TypeError(f\"Unsupported source type {type(s)}\")","tryCatchPattern":"try:\n    result = converter.run(sources=sources)\nexcept ValueError as e:\n    if \"Unsupported source type\" in str(e):\n        sources = [as_source(s) for s in sources]\n        result = converter.run(sources=sources)\n    else:\n        raise","preventionTips":["Normalize all inputs to ByteStream in one ingestion step before converters","Use LinkContentFetcher for URLs instead of passing them as sources","Log type(s) of sources when debugging pipeline wiring between components"],"tags":["python","valueerror","type-error","invalid-argument"],"backgroundTag":"unsupported-input-type","analyzedSha":"e318778c9bf60a1963e3b5f451359655dd696c30","analyzedAt":"2026-08-30T11:45:20.711Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}