langflow-ai/langflow · warning · HTTPException
File too large
Error message
File too large
What it means
The agentic file router enforces MAX_FILE_SIZE_BYTES (imported from lfx's FileSystemToolComponent). If stat reports a size above the cap, it raises HTTP 413 'File too large' before reading any content, protecting the API from oversized payloads.
Source
Thrown at src/backend/base/langflow/agentic/api/files_router.py:167
raise HTTPException(status_code=404, detail="Not found") from None
if not resolved.exists() or resolved.is_dir():
logger.warning(
"agentic.files.read.missing user_id=%s path=%s resolved=%s exists=%s is_dir=%s",
current_user.id,
path,
resolved,
resolved.exists(),
resolved.is_dir(),
)
raise HTTPException(status_code=404, detail="Not found")
try:
size = resolved.stat().st_size
except OSError:
raise HTTPException(status_code=404, detail="Not found") from None
if size > MAX_FILE_SIZE_BYTES:
raise HTTPException(status_code=413, detail="File too large")
# Binary sniff before the full read — same heuristic the FS tool uses.
try:
head = _read_head_no_follow(resolved, BINARY_SNIFF_BYTES)
except (OSError, PermissionError):
raise HTTPException(status_code=404, detail="Not found") from None
if _looks_binary(head):
raise HTTPException(status_code=415, detail="Binary content not supported")
try:
body_bytes = _read_bytes_no_follow(resolved)
except (OSError, PermissionError):
raise HTTPException(status_code=404, detail="Not found") from None
# Audit log — relative path only, never the absolute sandbox-resolved path.
logger.info(
"agentic.files.read user_id=%s path=%s size=%d download=%s",
current_user.id,View on GitHub (pinned to 976ec789d2)
Solutions
- Read the file in slices if the API offers range/offset parameters; otherwise use a different transfer path (e.g. the storage service) for large files.
- Trim or split the file in the sandbox before reading (via the agent's FS tools).
- If you operate the deployment and genuinely need bigger reads, raise the FileSystemToolComponent size limit — do not bypass the check.
Defensive patterns
Strategy: validation
Validate before calling
MAX = 10 * 1024 * 1024 # mirror the deployed MAX_FILE_SIZE_BYTES
import os
if os.path.getsize(sandbox_path) > MAX:
use_bulk_transfer_instead(sandbox_path) Try / catch
if resp.status_code == 413:
split_or_stream_via_storage_service(path) # never blind-retry Prevention
- Keep sandbox artifacts small; route large files through the storage service.
- Have agents write summaries/trims rather than full datasets.
- Know the deployed MAX_FILE_SIZE_BYTES before serving files from sandboxes.
When it happens
Trigger: GET /api/v1/agentic/files on a sandbox file larger than MAX_FILE_SIZE_BYTES (e.g. a dataset, log, or binary the agent saved).
Common situations: Agent writes large tool output into the sandbox; user drops a big CSV/log and tries to preview it through the endpoint.
Related errors
- File size is larger than the maximum file size {max_file_siz
- Invalid path
- Not found
- Binary content not supported
- This endpoint is not available
AI-assisted analysis of langflow-ai/langflow@976ec789d2 (2026-08-14).
Data as JSON: /api/errors/bd14fac2a4b638b8.
Report an issue: GitHub.