{"record":{"id":"d346074dde7bb739","repo":"BerriAI/litellm","slug":"process-audio-file-does-not-accept-bare-str-tuple","errorCode":null,"errorMessage":"process_audio_file does not accept bare str tuple contents. Pass bytes, an open file handle, or a pathlib.Path.","messagePattern":"process_audio_file does not accept bare str tuple contents\\. Pass bytes, an open file handle, or a pathlib\\.Path\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/litellm_core_utils/audio_utils/utils.py","lineNumber":81,"sourceCode":"            \"an open file handle, a (filename, content) tuple, or a \"\n            \"pathlib.Path.\"\n        )\n    elif isinstance(audio_file, os.PathLike):\n        # File path or PathLike — PathLike is a Python-level type that\n        # HTTP form values can't fabricate.\n        file_path: Final = str(audio_file)\n        with open(file_path, \"rb\") as f:\n            file_content = f.read()\n        filename = file_path.split(\"/\")[-1]\n    elif isinstance(audio_file, tuple):\n        # Tuple format: (filename, content, content_type) or (filename, content)\n        if len(audio_file) >= 2:\n            filename = audio_file[0] or \"audio.wav\"\n            content: Final = audio_file[1]\n            if isinstance(content, (bytes, bytearray)):\n                file_content = bytes(content)\n            elif isinstance(content, str):\n                raise ValueError(\n                    \"process_audio_file does not accept bare str tuple \"\n                    \"contents. Pass bytes, an open file handle, or a \"\n                    \"pathlib.Path.\"\n                )\n            elif isinstance(content, os.PathLike):\n                # PathLike: SDK convenience for local-file uploads.\n                with open(str(content), \"rb\") as f:\n                    file_content = f.read()\n            elif hasattr(content, \"read\"):\n                # File-like object\n                file_content = content.read()\n                if hasattr(content, \"seek\"):\n                    content.seek(0)\n            else:\n                raise ValueError(f\"Unsupported content type in tuple: {type(content)}\")\n        else:\n            raise ValueError(\"Tuple must have at least 2 elements: (filename, content)\")\n    elif hasattr(audio_file, \"read\") and not isinstance(audio_file, (str, bytes, bytearray, tuple, os.PathLike)):","sourceCodeStart":63,"sourceCodeEnd":99,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/litellm_core_utils/audio_utils/utils.py#L63-L99","documentation":"Input validation in process_audio_file: the audio file was given as a (filename, content) tuple but the content element is a bare str. Because a str could be a path or raw text and is ambiguous/injectable over HTTP forms, the helper rejects it and asks for bytes, a file handle, or a Path.","triggerScenarios":"Thrown at litellm/litellm_core_utils/audio_utils/utils.py:81 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["In the (filename, content) tuple, make content bytes, an open file handle, or a pathlib.Path - not a bare string.","Read the file into bytes first, e.g. (name, open(path,'rb').read())."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}