{"record":{"id":"e9e04daee13e83eb","repo":"jamiepine/voicebox","slug":"audio-exceeds-max-transcribe-bytes-1024-102","errorCode":null,"errorMessage":"Audio exceeds {MAX_TRANSCRIBE_BYTES // (1024 * 1024)} MB limit.","messagePattern":"Audio exceeds (.+?) MB limit\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"backend/mcp_server/tools.py","lineNumber":160,"sourceCode":"                )\n            path = Path(audio_path)\n            if not path.is_absolute():\n                raise ValueError(\"`audio_path` must be absolute.\")\n            if not path.is_file():\n                raise ValueError(f\"File not found: {audio_path}\")\n            if path.stat().st_size > MAX_TRANSCRIBE_BYTES:\n                raise ValueError(\n                    f\"File exceeds {MAX_TRANSCRIBE_BYTES // (1024 * 1024)} MB limit.\"\n                )\n            return await _transcribe_file(path, language, model)\n\n        # Base64 mode: decode into a temp file, transcribe, clean up.\n        try:\n            raw = b64.b64decode(audio_base64, validate=True)\n        except Exception as exc:\n            raise ValueError(f\"Invalid audio_base64: {exc}\") from exc\n        if len(raw) > MAX_TRANSCRIBE_BYTES:\n            raise ValueError(\n                f\"Audio exceeds {MAX_TRANSCRIBE_BYTES // (1024 * 1024)} MB limit.\"\n            )\n        with tempfile.NamedTemporaryFile(\n            suffix=\".wav\", delete=False\n        ) as tmp:\n            tmp.write(raw)\n            tmp_path = Path(tmp.name)\n        try:\n            return await _transcribe_file(tmp_path, language, model)\n        finally:\n            tmp_path.unlink(missing_ok=True)\n\n    @mcp.tool(\n        name=\"voicebox.list_captures\",\n        description=(\n            \"List recent voice captures (dictations, recordings, uploads) \"\n            \"with their transcripts. Most-recent first.\"\n        ),","sourceCodeStart":142,"sourceCodeEnd":178,"githubUrl":"https://github.com/jamiepine/voicebox/blob/51f49dea198384b4eb6087b72c17057c6eb1c1cd/backend/mcp_server/tools.py#L142-L178","documentation":"Raised by voicebox_transcribe in base64 mode when the decoded byte length len(raw) exceeds MAX_TRANSCRIBE_BYTES (200 MB). Unlike error 50 this fires after decoding, so it guards inflated base64 payloads rather than on-disk file size.","triggerScenarios":"Sending a base64-encoded clip whose decoded content is over 200 MB; base64 of a >150 MB binary will already approach the cap (base64 inflation is ~4/3).","commonSituations":"Long uncompressed audio shipped via base64; transport ceiling lower than the decode cap so the payload often fails earlier; client assuming the limit applies to the encoded size, not decoded.","solutions":["Reduce the decoded audio to under 200 MB (trim, segment, or re-encode to 16 kHz mono).","For local clients, switch to audio_path to skip the base64 round trip and the same 200 MB cap on file size.","Batch long recordings into multiple under-limit calls."],"exampleFix":"// before\nvoicebox_transcribe(audio_base64=b64encode(huge_wav))\n// after\nsegments = split(huge_wav, max_bytes=150*1024*1024)\nfor s in segments: voicebox_transcribe(audio_base64=b64encode(s))","handlingStrategy":"validation","validationCode":"import base64\nfrom backend.mcp_server.tools import MAX_TRANSCRIBE_BYTES\nraw = base64.b64decode(audio_base64, validate=True)\nif len(raw) > MAX_TRANSCRIBE_BYTES:\n    raise ValueError(\"decoded audio exceeds 200 MB; segment it first\")\nawait voicebox_transcribe(audio_base64=audio_base64)","typeGuard":"def decoded_audio_under_limit(value: str, limit: int = 200 * 1024 * 1024) -> bool:\n    import base64\n    try:\n        return len(base64.b64decode(value, validate=True)) <= limit\n    except Exception:\n        return False","tryCatchPattern":"try:\n    await voicebox_transcribe(audio_base64=audio_base64)\nexcept ValueError as exc:\n    if \"exceeds\" in str(exc) and \"MB limit\" in str(exc):\n        for chunk in segment_audio_bytes(raw, max_bytes=150 * 1024 * 1024):\n            await voicebox_transcribe(audio_base64=base64.b64encode(chunk).decode())\n    else:\n        raise","preventionTips":["Remember the limit applies to decoded bytes, not the base64 string length.","For large local files, use audio_path (loopback) to avoid base64 overhead.","Down-sample/segment long recordings before encoding."],"tags":["mcp","size-limit","base64","transcription"],"backgroundTag":null,"analyzedSha":"51f49dea198384b4eb6087b72c17057c6eb1c1cd","analyzedAt":"2026-08-12T16:51:42.824Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}