{"record":{"id":"cb68064d6cf0b374","repo":"BerriAI/litellm","slug":"calculate-request-duration-does-not-accept-bare-st","errorCode":null,"errorMessage":"calculate_request_duration does not accept bare str inputs. Pass bytes, an open file handle, a (filename, content) tuple, or a pathlib.Path.","messagePattern":"calculate_request_duration does not accept bare str inputs\\. Pass bytes, an open file handle, a \\(filename, content\\) tuple, or a pathlib\\.Path\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/litellm_core_utils/audio_utils/utils.py","lineNumber":279,"sourceCode":"    \"\"\"\n    try:\n        import soundfile as sf\n    except ImportError:\n        # soundfile not available, cannot extract duration\n        return None\n\n    try:\n        import io\n\n        # Handle different file input types\n        file_content: bytes | None = None\n\n        if isinstance(file, (bytes, bytearray)):\n            # Raw bytes\n            file_content = bytes(file)\n        elif isinstance(file, str):\n            # Bare strings are rejected — see extract_file_data.\n            raise ValueError(\n                \"calculate_request_duration does not accept bare str inputs. \"\n                \"Pass bytes, an open file handle, a (filename, content) \"\n                \"tuple, or a pathlib.Path.\"\n            )\n        elif isinstance(file, os.PathLike):\n            # File path (PathLike): SDK convenience.\n            with open(str(file), \"rb\") as f:\n                file_content = f.read()\n        elif isinstance(file, tuple):\n            # Tuple format: (filename, content, optional content_type)\n            if len(file) >= 2:\n                content: Final = file[1]\n                if isinstance(content, bytes):\n                    file_content = content\n                elif hasattr(content, \"read\") and not isinstance(content, (str, os.PathLike)):\n                    # File-like object in tuple\n                    current_pos: Final = getattr(content, \"tell\", lambda: None)()\n                    # Seek to start to ensure we read the entire content","sourceCodeStart":261,"sourceCodeEnd":297,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/litellm_core_utils/audio_utils/utils.py#L261-L297","documentation":"Error \"calculate_request_duration does not accept bare str inputs. Pass bytes, an open file handle, a (filename, content) tuple, or a pathlib.Path.\" thrown in BerriAI/litellm.","triggerScenarios":"Thrown at litellm/litellm_core_utils/audio_utils/utils.py:279 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass bytes, an open file handle, a (filename, content) tuple, or a pathlib.Path instead of a bare string."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}