{"record":{"id":"bd14fac2a4b638b8","repo":"langflow-ai/langflow","slug":"file-too-large","errorCode":null,"errorMessage":"File too large","messagePattern":"File too large","errorType":"http","errorClass":"HTTPException","httpStatus":413,"severity":"warning","filePath":"src/backend/base/langflow/agentic/api/files_router.py","lineNumber":167,"sourceCode":"        raise HTTPException(status_code=404, detail=\"Not found\") from None\n\n    if not resolved.exists() or resolved.is_dir():\n        logger.warning(\n            \"agentic.files.read.missing user_id=%s path=%s resolved=%s exists=%s is_dir=%s\",\n            current_user.id,\n            path,\n            resolved,\n            resolved.exists(),\n            resolved.is_dir(),\n        )\n        raise HTTPException(status_code=404, detail=\"Not found\")\n\n    try:\n        size = resolved.stat().st_size\n    except OSError:\n        raise HTTPException(status_code=404, detail=\"Not found\") from None\n    if size > MAX_FILE_SIZE_BYTES:\n        raise HTTPException(status_code=413, detail=\"File too large\")\n\n    # Binary sniff before the full read — same heuristic the FS tool uses.\n    try:\n        head = _read_head_no_follow(resolved, BINARY_SNIFF_BYTES)\n    except (OSError, PermissionError):\n        raise HTTPException(status_code=404, detail=\"Not found\") from None\n    if _looks_binary(head):\n        raise HTTPException(status_code=415, detail=\"Binary content not supported\")\n\n    try:\n        body_bytes = _read_bytes_no_follow(resolved)\n    except (OSError, PermissionError):\n        raise HTTPException(status_code=404, detail=\"Not found\") from None\n\n    # Audit log — relative path only, never the absolute sandbox-resolved path.\n    logger.info(\n        \"agentic.files.read user_id=%s path=%s size=%d download=%s\",\n        current_user.id,","sourceCodeStart":149,"sourceCodeEnd":185,"githubUrl":"https://github.com/langflow-ai/langflow/blob/976ec789d2886a86de109c044d089d68e96c9a35/src/backend/base/langflow/agentic/api/files_router.py#L149-L185","documentation":"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.","triggerScenarios":"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).","commonSituations":"Agent writes large tool output into the sandbox; user drops a big CSV/log and tries to preview it through the endpoint.","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."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"MAX = 10 * 1024 * 1024  # mirror the deployed MAX_FILE_SIZE_BYTES\nimport os\nif os.path.getsize(sandbox_path) > MAX:\n    use_bulk_transfer_instead(sandbox_path)","typeGuard":null,"tryCatchPattern":"if resp.status_code == 413:\n    split_or_stream_via_storage_service(path)  # never blind-retry","preventionTips":["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."],"tags":["agentic","files","http-413","size-limit"],"backgroundTag":null,"analyzedSha":"976ec789d2886a86de109c044d089d68e96c9a35","analyzedAt":"2026-08-14T18:23:12.227Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}