langflow-ai/langflow · error · HTTPException

Flow not found

Error message

Flow not found

What it means

The get_flow dependency for the files API returns 404 'Flow not found' when session.get(Flow, flow_id) returns nothing OR when the flow exists but belongs to a different user. The single message for both cases is deliberate: it prevents information disclosure about which flow IDs exist. Any files route hit with a foreign/nonexistent flow_id (upload, download, images) fails here before the handler runs.

Source

Thrown at src/backend/base/langflow/api/v1/files.py:79

        logger.exception("Exception occurred while getting allowed profile picture folders")

    # Sensible defaults ensure tests and OOTB behavior
    return allowed or {"People", "Space"}


# Create dep that gets the flow_id from the request
# then finds it in the database and returns it while
# using the current user as the owner
async def get_flow(
    flow_id: UUID,
    current_user: CurrentActiveUser,
    session: DbSession,
):
    # AttributeError: 'SelectOfScalar' object has no attribute 'first'
    flow = await session.get(Flow, flow_id)
    # Return 404 for both non-existent flows and unauthorized access to prevent information disclosure
    if not flow or flow.user_id != current_user.id:
        raise HTTPException(status_code=404, detail="Flow not found")
    return flow


@router.post("/upload/{flow_id}", status_code=HTTPStatus.CREATED)
async def upload_file(
    *,
    file: UploadFile,
    flow: Annotated[Flow, Depends(get_flow)],
    current_user: CurrentActiveUser,
    storage_service: Annotated[StorageService, Depends(get_storage_service)],
    settings_service: Annotated[SettingsService, Depends(get_settings_service)],
) -> UploadFileResponse:
    # Writing a file to a flow's storage is a flow mutation: enforce WRITE so
    # the external access ceiling (e.g. a "viewer") cannot upload via this route.
    await ensure_flow_permission(
        current_user,
        FlowAction.WRITE,
        flow_id=flow.id,

View on GitHub (pinned to 976ec789d2)

Solutions

  1. Verify the flow_id exists and is owned by the current user: GET /api/v1/flows/{flow_id} as the same credentials
  2. Re-authenticate as the user who owns the flow, or have the flow shared/transferred to you
  3. If the flow was deleted, recreate it and re-upload files against the new flow_id
  4. Check you are not pointing at another workspace's flow (multi-user instance)

Example fix

// before
await api.post(`/files/upload/${oldFlowId}`, formData); // 404

// after
const flow = await api.get(`/flows/${flowId}`); // confirm 200 first
await api.post(`/files/upload/${flow.data.id}`, formData);
Defensive patterns

Strategy: validation

Validate before calling

def flow_accessible(client, flow_id: str) -> bool:
    resp = client.get(f"/api/v1/flows/{flow_id}")
    return resp.status_code == 200

Type guard

import uuid

def is_valid_flow_id(flow_id: str) -> bool:
    try:
        uuid.UUID(flow_id)
        return True
    except ValueError:
        return False

Try / catch

try:
    client.get(f"/api/v1/files/download/{flow_id}/{name}").raise_for_status()
except HTTPError as e:
    if e.response.status_code == 404:
        refresh_flow_list()  # flow deleted or not owned by this user
    raise

Prevention

When it happens

Trigger: POST /api/v1/files/upload/{flow_id} with a mistyped or deleted flow_id; GET /files/download/{flow_id}/{file} where the authenticated user is not the flow owner; using credentials of a different user than the one who created the flow.

Common situations: Session/token switched between creating the flow and uploading the file; flow deleted by another admin; copy-pasting a download URL between accounts; stale flow_id cached in frontend after a re-import.

Related errors


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