langflow-ai/langflow · error · HTTPException
Invalid JSON: expected an object with 'flows' or a single fl
Error message
Invalid JSON: expected an object with 'flows' or a single flow object
What it means
Error "Invalid JSON: expected an object with 'flows' or a single flow object" thrown in langflow-ai/langflow.
Source
Thrown at src/backend/base/langflow/api/v1/flows.py:681
if zipfile.is_zipfile(io.BytesIO(contents)):
try:
flows_data = await extract_flows_from_zip(contents)
except ValueError as e:
raise HTTPException(status_code=400, detail=str(e)) from e
if not flows_data:
raise HTTPException(status_code=400, detail="No valid flow JSON files found in the ZIP")
data = {"flows": flows_data}
else:
try:
data = orjson.loads(contents)
except orjson.JSONDecodeError as e:
raise HTTPException(status_code=400, detail=f"Invalid JSON file: {e}") from e
# Normalise code fields: if exported with code-as-lines format, rejoin to
# strings before creating the Pydantic models so the DB always stores strings.
if not isinstance(data, dict):
raise HTTPException(
status_code=422,
detail="Invalid JSON: expected an object with 'flows' or a single flow object",
)
try:
if "flows" in data:
if not isinstance(data["flows"], list):
raise HTTPException(
status_code=422,
detail="Invalid JSON: 'flows' must be a list of flow objects",
)
non_dict = [i for i, f in enumerate(data["flows"]) if not isinstance(f, dict)]
if non_dict:
raise HTTPException(
status_code=422,
detail=f"Invalid JSON: flows[{non_dict[0]}] is not an object",
)
data = {**data, "flows": [normalize_code_for_import(f) for f in data["flows"]]}
flow_list = FlowListCreate(**data)View on GitHub (pinned to 976ec789d2)
Solutions
- Upload a JSON object containing a 'flows' list, or a single flow object.
When it happens
Trigger: Occurs when the uploaded JSON is neither an object containing a 'flows' key nor a single flow object.
Common situations: See trigger scenarios.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
AI-assisted analysis of langflow-ai/langflow@976ec789d2 (2026-08-14).
Data as JSON: /api/errors/d7b4decb23256e16.
Report an issue: GitHub.