langflow-ai/langflow · error · HTTPException

File {uploaded_file.filename} exceeds the maximum upload siz

Error message

File {uploaded_file.filename} exceeds the maximum upload size of {max_file_size_upload}MB

What it means

Raised by the knowledge-base file upload endpoint when an uploaded file's size exceeds the server-configured maximum upload size (max_file_size_upload, in MB, from Langflow settings). It is a 413 Payload Too Large returned per-file while iterating the multipart upload, before any bytes are read into memory. Only files over the limit fail; the whole request is aborted at the first offending file.

Source

Thrown at src/backend/base/langflow/api/v1/knowledge_bases.py:1052

    """
    _kb_guard = await _guard_kb_action(current_user=current_user, action=KnowledgeBaseAction.INGEST, kb_name=kb_name)
    _assert_kb_not_memory_base(kb_name, _kb_guard.owner_user)
    try:
        settings = get_settings_service().settings
        max_file_size_upload = settings.max_file_size_upload

        # Parse + validate metadata before reading any file bytes so a bad
        # metadata payload fails fast with 422 instead of paying the upload
        # cost first.
        run_metadata = parse_user_metadata(metadata)
        per_file_metadata_dict = parse_per_file_metadata(per_file_metadata)

        files_data = []

        for uploaded_file in files:
            file_size = uploaded_file.size
            if file_size > max_file_size_upload * 1024 * 1024:
                raise HTTPException(
                    status_code=413,
                    detail=f"File {uploaded_file.filename} exceeds the maximum upload size of {max_file_size_upload}MB",
                )
            content = await uploaded_file.read()
            files_data.append((uploaded_file.filename or "unknown", content))

        kb_path = _resolve_kb_path(kb_name, _kb_guard.owner_user)

        # Parse and persist column_config from FormData if provided
        if column_config:
            try:
                column_config_parsed = json.loads(column_config)
                if isinstance(column_config_parsed, list):
                    # Update embedding_metadata.json
                    cc_metadata_path = kb_path / "embedding_metadata.json"
                    if cc_metadata_path.exists():
                        existing_meta = json.loads(cc_metadata_path.read_text())
                        existing_meta["column_config"] = column_config_parsed

View on GitHub (pinned to 976ec789d2)

Solutions

  1. Increase the limit in settings: set max_file_size_upload (env LANGFLOW_MAX_FILE_SIZE_UPLOAD or via settings UI/config) to a value large enough for your largest file, then restart the backend.
  2. Pre-filter files client-side so the batch only contains files under max_file_size_upload MB, and split large files out.
  3. For oversized documents, chunk/split the file or ingest via the folder-ingest endpoint if the operator's per-file limit there is higher.
  4. If behind a proxy, also raise its body-size limit (e.g. nginx client_max_body_size) to match.

Example fix

# before: uploading a 200MB file with default limit
await client.post(f"/api/v1/knowledge_bases/{kb}/upload", files=files)

# after: raise server limit in settings
# LANGFLOW_MAX_FILE_SIZE_UPLOAD=500
# and check client-side before uploading
import os
MAX_MB = 100
files = [(name, f) for name, f in files if os.path.getsize(f.name) <= MAX_MB * 1024 * 1024]
Defensive patterns

Strategy: validation

Validate before calling

import os

MAX_MB = int(os.environ.get("LANGFLOW_MAX_FILE_SIZE_UPLOAD", "100"))

def filter_uploadable(paths: list[str]) -> list[str]:
    return [p for p in paths if os.path.getsize(p) <= MAX_MB * 1024 * 1024]

Try / catch

try:
    resp = await client.post(f"/api/v1/knowledge_bases/{kb}/upload", files=files)
except HTTPError as e:
    if e.response.status_code == 413:
        # split oversized files out of the batch and retry with the rest
        ...

Prevention

When it happens

Trigger: POST multipart upload of one or more files to /api/v1/knowledge_bases/{kb_name}/upload (file ingest) where any uploaded_file.size > max_file_size_upload * 1024 * 1024. The check runs before uploaded_file.read(), so a single oversized file in a multi-file batch rejects the entire request.

Common situations: Default Langflow max_file_size_upload is small (a few MB), so PDFs, datasets, or model files routinely exceed it. Operators behind reverse proxies (nginx client_max_body_size) may see a different error first. Users uploading batches where one large file slips in.

Related errors


AI-assisted analysis of langflow-ai/langflow@976ec789d2 (2026-08-14). Data as JSON: /api/errors/90b76850259f507b. Report an issue: GitHub.