langflow-ai/langflow · warning · HTTPException
Folder not found
Error message
Folder not found
What it means
HTTP 400 from _create_flow's upsert path: validate_folder was enabled (external-source/PUT upsert) and the submitted folder_id does not exist or does not belong to the acting user (query filters on both Folder.id and Folder.user_id). This stops external syncs from landing flows in another user's folder or a nonexistent one.
Source
Thrown at src/backend/base/langflow/api/v1/flows_helpers.py:318
Args:
session: Database session.
flow: Flow creation data.
user_id: Owner of the new flow.
storage_service: Service for filesystem operations.
flow_id: Allows PUT upsert to create flows with a specific ID for syncing between instances.
fail_on_endpoint_conflict: PUT should fail predictably on conflicts rather than silently renaming.
validate_folder: Validates folder_id exists and belongs to user when upserting from external sources.
"""
try:
await _verify_fs_path(flow.fs_path, user_id, storage_service)
if validate_folder and flow.folder_id is not None:
folder = (
await session.exec(select(Folder).where(Folder.id == flow.folder_id, Folder.user_id == user_id))
).first()
if not folder:
raise HTTPException(status_code=400, detail="Folder not found")
# Set user_id (ignore any user_id from body for security)
flow.user_id = user_id
flow.name = await _deduplicate_flow_name(session, flow.name, user_id)
if flow.endpoint_name:
flow.endpoint_name = await _deduplicate_endpoint_name(
session, flow.endpoint_name, user_id, fail_on_conflict=fail_on_endpoint_conflict
)
# Exclude the id field from FlowCreate so that Flow.id (UUID, non-optional)
# always gets its default_factory uuid4 unless we explicitly override it below.
db_flow = Flow.model_validate(flow.model_dump(exclude={"id"}))
# Apply the stable ID: explicit flow_id param (PUT upsert) takes precedence,
# then flow.id (stable import from FlowCreate), then the uuid4 default.
effective_id = flow_id if flow_id is not None else flow.id
if effective_id is not None:View on GitHub (pinned to 976ec789d2)
Solutions
- GET /api/v1/folders (as the same user) and use an id from that list.
- Omit folder_id to let the flow land in the default folder.
- Create the folder first when it is missing, then retry the upsert.
- If syncing across instances, map folder names -> local ids instead of trusting foreign ids.
Example fix
# before
{"name":"f","folder_id":"<uuid-from-other-instance>"}
# after
folders = await client.get('/api/v1/folders')
folder = next(f for f in folders if f['name'] == 'Sync')
{"name":"f","folder_id":folder['id']} Defensive patterns
Strategy: validation
Validate before calling
const folders = await listFolders(); if (body.folder_id && !folders.some(f => f.id === body.folder_id)) delete body.folder_id;
Prevention
- Always resolve folder ids via GET /api/v1/folders for the current user
- Map folder names to local ids in cross-instance syncs
- Omit folder_id to use the default folder
When it happens
Trigger: PUT upsert with folder_id of a deleted folder, a folder owned by a different user, or a folder id copied from another instance/environment.
Common situations: Cross-instance sync where folder ids differ per instance; folder was deleted after the sync payload was built; client reuses ids from a staging environment against production.
Related errors
- fs_path cannot be empty
- str(e)
- Failed to install MCP
- Invalid path
- Provider '{provider}' is not configured. Available providers
AI-assisted analysis of langflow-ai/langflow@976ec789d2 (2026-08-14).
Data as JSON: /api/errors/252b291baf158cfc.
Report an issue: GitHub.