{"record":{"id":"eb57926012450653","repo":"Panniantong/Agent-Reach","slug":"label-exceeds-safety-limit-of-limit-mib-g-mib","errorCode":null,"errorMessage":"{label} exceeds safety limit of {limit_mib:g} MiB","messagePattern":"(.+?) exceeds safety limit of (.+?) MiB","errorType":"exception","errorClass":"TranscribeError","httpStatus":null,"severity":"error","filePath":"agent_reach/transcribe.py","lineNumber":88,"sourceCode":"\n\n_BLOCKED_HOSTS = {\n    \"localhost\",\n    \"metadata.google.internal\",\n}\n\n\ndef _require(binary: str) -> None:\n    if not shutil.which(binary):\n        raise MissingDependency(f\"{binary} not found in PATH\")\n\n\ndef _require_size_at_most(path: Path, limit: int, label: str) -> int:\n    \"\"\"Return file size or fail before expensive downstream processing.\"\"\"\n    size = path.stat().st_size\n    if size > limit:\n        limit_mib = limit / (1024 * 1024)\n        raise TranscribeError(f\"{label} exceeds safety limit of {limit_mib:g} MiB\")\n    return size\n\n\ndef _probe_audio_duration(path: Path) -> float:\n    \"\"\"Return duration in seconds or fail closed before media generation.\"\"\"\n    _require(\"ffprobe\")\n    cmd = [\n        \"ffprobe\",\n        \"-v\",\n        \"error\",\n        \"-show_entries\",\n        \"format=duration\",\n        \"-of\",\n        \"default=noprint_wrappers=1:nokey=1\",\n        \"-i\",\n        str(path),\n    ]\n    try:","sourceCodeStart":70,"sourceCodeEnd":106,"githubUrl":"https://github.com/Panniantong/Agent-Reach/blob/93ae1d18c37b707dec053c7c4f9d91cd8ef8943d/agent_reach/transcribe.py#L70-L106","documentation":"Raised by _require_size_at_most() in agent_reach/transcribe.py when an input media file's on-disk size exceeds the configured safety limit. The check runs before any expensive processing so an oversized upload fails immediately. The limit is formatted in MiB in the message (label identifies which artifact — input or chunk — was too large).","triggerScenarios":"Passing a multi-hundred-MB audio/video file to the transcribe pipeline; regenerated chunks or concatenated media exceeding the byte cap during processing.","commonSituations":"Transcribing long downloads (podcast archives, multi-hour streams) without pre-compression; disk-full conditions during chunking inflating partial files.","solutions":["Compress or downsample the media first (e.g. ffmpeg -i in.mp3 -b:a 48k out.m4a) to get under the limit","Trim the file into smaller segments and transcribe each separately","Read the message's MiB figure and check your file with `ls -l` or os.path.getsize before retrying"],"exampleFix":"# before\ntranscribe_audio(Path('huge_recording.wav'))  # exceeds safety limit\n\n# after: compress first\nsubprocess.run(['ffmpeg', '-i', 'huge_recording.wav', '-b:a', '48k', 'small.m4a'])\ntranscribe_audio(Path('small.m4a'))","handlingStrategy":"validation","validationCode":"size = path.stat().st_size\nif size > MAX_MEDIA_BYTES:  # mirror the module's limit\n    raise ValueError(f'{path} is {size/2**20:.0f} MiB; compress or split first')","typeGuard":"def within_size_limit(path, limit: int) -> bool:\n    return path.stat().st_size <= limit","tryCatchPattern":"from agent_reach.transcribe import TranscribeError\ntry:\n    transcribe_audio(path)\nexcept TranscribeError as e:\n    if 'safety limit' in str(e):\n        compress(path)  # ffmpeg -b:a 48k, then retry once\n    else:\n        raise","preventionTips":["Check file size before calling transcribe","Compress long recordings to low-bitrate mono before transcription","Read the MiB figure in the message to know the exact cap"],"tags":["size-limit","safety","media","transcription"],"backgroundTag":null,"analyzedSha":"93ae1d18c37b707dec053c7c4f9d91cd8ef8943d","analyzedAt":"2026-08-14T22:54:06.735Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}