{"record":{"id":"4c44b921f5deb028","repo":"PrefectHQ/fastmcp","slug":"no-audio-data-available","errorCode":null,"errorMessage":"No audio data available","messagePattern":"No audio data available","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"fastmcp_slim/fastmcp/utilities/types.py","lineNumber":366,"sourceCode":"\n        if self.path:\n            return mapping.get(\n                self.path.suffix.lower().lstrip(\".\"), \"application/octet-stream\"\n            )\n        return \"audio/wav\"  # default for raw binary data\n\n    def to_audio_content(\n        self,\n        mime_type: str | None = None,\n        annotations: Annotations | None = None,\n    ) -> mcp_types.AudioContent:\n        if self.path:\n            with open(self.path, \"rb\") as f:\n                data = base64.b64encode(f.read()).decode()\n        elif self.data is not None:\n            data = base64.b64encode(self.data).decode()\n        else:\n            raise ValueError(\"No audio data available\")\n\n        return mcp_types.AudioContent(\n            type=\"audio\",\n            data=data,\n            mime_type=mime_type or self._mime_type,\n            annotations=annotations or self.annotations,\n        )\n\n\nclass File:\n    \"\"\"Helper class for returning file data from tools.\"\"\"\n\n    def __init__(\n        self,\n        path: str | Path | None = None,\n        data: bytes | None = None,\n        format: str | None = None,\n        name: str | None = None,","sourceCodeStart":348,"sourceCodeEnd":384,"githubUrl":"https://github.com/PrefectHQ/fastmcp/blob/1f021142978e0861cd910c8df4e8074bc7cf3978/fastmcp_slim/fastmcp/utilities/types.py#L348-L384","documentation":"Audio.to_audio_content() base64-encodes the audio from path or data to build MCP AudioContent. If the object has neither a truthy path nor data at call time, it raises ValueError('No audio data available') — the instance holds no usable audio source.","triggerScenarios":"Calling to_audio_content() (directly or via get_audio / _convert_to_single_content_block) on an Audio with path=None/'' and data=None, e.g. after deserialization or post-construction mutation.","commonSituations":"Audio objects round-tripped through serialization losing the data attribute; empty-string paths; building Audio in one component and clearing data before conversion.","solutions":["Recreate the Audio with a valid path or non-empty bytes before converting","Check audio.path / audio.data before calling to_audio_content()","Ensure the path is a non-empty string and the file exists"],"exampleFix":"// before\naudio = Audio(path='')  # no usable source\nblock = audio.to_audio_content()  # raises\n// after\naudio = Audio(path='clip.wav')\nblock = audio.to_audio_content()","handlingStrategy":"type-guard","validationCode":"def to_audio(audio: Audio):\n    if not audio.path and audio.data is None:\n        raise ValueError(\"Audio has no path or data; rebuild it\")\n    return audio.to_audio_content()","typeGuard":"def has_audio_data(audio: Audio) -> bool:\n    return bool(audio.path) or audio.data is not None","tryCatchPattern":"try:\n    block = audio.to_audio_content()\nexcept ValueError:\n    block = None  # skip or reload the audio from the original source","preventionTips":["Preserve the original path/bytes so Audio can be rebuilt","Never clear .data on an Audio instance before conversion","When serializing, persist the bytes instead of relying on a transient path"],"tags":["audio","state","valueerror"],"backgroundTag":"missing-required-argument","analyzedSha":"1f021142978e0861cd910c8df4e8074bc7cf3978","analyzedAt":"2026-08-29T14:31:16.082Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}