affaan-m/ECC · error · FalError
download exceeds maximum allowed size
Error message
download exceeds maximum allowed size
What it means
While streaming the response body, download() accumulates bytes and aborts as soon as total exceeds MAX_DOWNLOAD_BYTES. This catches cases the Content-Length check cannot: chunked transfer-encoding with no declared length, or a server that sends more than it declared.
Solutions
- Check the actual size of the asset (e.g. via a HEAD request) before downloading
- Increase MAX_DOWNLOAD_BYTES if the workload legitimately needs larger files
- Use a smaller/max-duration generation option in the fal API call so outputs stay under the limit
- Free disk/write to a stream instead if you need unbounded downloads (requires code change)
Example fix
// before MAX_DOWNLOAD_BYTES = 50 * 1024 * 1024 # too small for 4K video // after MAX_DOWNLOAD_BYTES = 512 * 1024 * 1024
Defensive patterns
Strategy: validation
Validate before calling
size = int(urllib.request.urlopen(urllib.request.Request(url, method="HEAD")).headers["Content-Length"])
if size > MAX_DOWNLOAD_BYTES:
raise ValueError("asset too large to download") Try / catch
try:
download(url, dest)
except FalError as e:
if "exceeds maximum" in str(e):
request_smaller_asset(url) # or raise MAX_DOWNLOAD_BYTES deliberately Prevention
- HEAD-request size before download
- Constrain generation parameters (resolution/duration) so outputs stay under the limit
- Monitor MAX_DOWNLOAD_BYTES against real asset sizes
When it happens
Trigger: Downloading a response that streams more than MAX_DOWNLOAD_BYTES bytes, either via chunked encoding (no Content-Length) or by lying about its declared length.
Common situations: A generation returned an unexpectedly enormous video; a redirect to a large file; a malicious or broken server streaming unbounded data; misjudging MAX_DOWNLOAD_BYTES for long clips.
Understand the failure class
Background: "File too large" / "file size exceeds limit" errors: why libraries cap file sizes and how to fix them — this error's family across 46 libraries.
Related errors
- Control-plane request failed
- download declares an invalid or excessive size
- download declares an invalid or excessive size
- download declares an invalid or excessive size
- download exceeds maximum allowed size
AI-assisted analysis of affaan-m/ECC@8321021c54 (2026-09-16).
Data as JSON: /api/errors/365c09a15d901870.
Report an issue: GitHub.
Appendix: source
Thrown at skills/taste-distillation/scripts/taste/falapi.py:712
opener = urllib.request.build_opener(_SafeRedirect())
temporary = None
try:
with opener.open(req, timeout=300) as resp:
declared = getattr(resp, "headers", {}).get("Content-Length")
expected = int(declared) if declared is not None else None
if expected is not None and not 0 <= expected <= MAX_DOWNLOAD_BYTES:
raise FalError("download declares an invalid or excessive size")
with tempfile.NamedTemporaryFile(dir=dest.parent, prefix=".taste-download-",
delete=False) as fh:
temporary = Path(fh.name)
total = 0
while True:
chunk = resp.read(min(1024 * 1024, MAX_DOWNLOAD_BYTES - total + 1))
if not chunk:
break
total += len(chunk)
if total > MAX_DOWNLOAD_BYTES:
raise FalError("download exceeds maximum allowed size")
fh.write(chunk)
if expected is not None and total != expected:
raise FalError("download length does not match declared size")
os.replace(temporary, dest)
temporary = None
except FalError:
raise
except Exception:
raise FalError("download failed; existing destination preserved") from None
finally:
if temporary is not None:
temporary.unlink(missing_ok=True)
return dest
# ---------------------------------------------------------------------------
# dry-run stubs
# ---------------------------------------------------------------------------View on GitHub (pinned to 8321021c54)