langflow-ai/langflow · error · ValueError
Error serializing vertex build response: {exc}
Error message
Error serializing vertex build response: {exc} What it means
A ValueError raised when a vertex build succeeded but its VertexBuildResponse cannot be serialized with model_dump_json()/json.loads() before emitting the on_end_vertex event. This indicates the response model contains data that pydantic cannot dump to JSON — typically non-serializable objects placed in the output data by a custom component.
Source
Thrown at src/backend/base/langflow/api/build.py:831
# Why: the background path never enters Graph.process(), so the pause boundary must live in this driver.
await graph.check_and_handle_pause()
try:
vertex_build_response: VertexBuildResponse = await _build_vertex(vertex_id, graph, event_manager)
except asyncio.CancelledError:
await logger.ainfo("Build cancelled")
raise
# Accumulate the vertex timedelta
if vertex_build_response.data.timedelta is not None:
vertex_timedeltas.append(vertex_build_response.data.timedelta)
# send built event or error event
try:
vertex_build_response_json = vertex_build_response.model_dump_json()
build_data = json.loads(vertex_build_response_json)
except Exception as exc:
msg = f"Error serializing vertex build response: {exc}"
raise ValueError(msg) from exc
event_manager.on_end_vertex(
data={"build_data": build_data, "output_meta": _output_meta_for_vertex(graph, vertex_id)}
)
if vertex_build_response.valid and vertex_build_response.next_vertices_ids:
tasks = []
for next_vertex_id in vertex_build_response.next_vertices_ids:
task = asyncio.create_task(
build_vertices(
next_vertex_id,
graph,
event_manager,
vertex_timedeltas,
)
)
tasks.append(task)
await asyncio.gather(*tasks)View on GitHub (pinned to 976ec789d2)
Solutions
- In the failing component, convert the output to a supported type (Message, Data, str, or a plain dict/list of primitives) before returning
- If returning rich objects, implement model_serializer / dict() conversion, or use repr()/str() for display outputs
- Pin consistent pydantic versions across the workspace if serialization behavior changed after upgrade
- Reproduce by building only that vertex to confirm the serialization fix
Example fix
# before
return Data(data={'result': some_llm_sdk_object}) # not JSON-dumpable
# after
return Data(data={'result': str(some_llm_sdk_object)})
# or the idiomatic way:
return Message(text=some_llm_sdk_object.content) Defensive patterns
Strategy: type-guard
Validate before calling
# before returning from a custom component, ensure JSON-serializability
import json
def safe_output(obj) -> str:
try:
json.dumps(obj)
return obj
except TypeError:
return str(obj) Type guard
from langflow.schema.message import Message
from langflow.schema import Data
from langflow.schema.dataframe import DataFrame
def is_serializable_output(v) -> bool:
return isinstance(v, (Message, Data, DataFrame, str, int, float, bool, list, dict, type(None))) Try / catch
try { ... } finally { /* vertex serialization failure is a server bug-class error: fix the component rather than catching at the edge */ } Prevention
- Return langflow types (Message/Data) from component outputs, never raw SDK objects
- Unit-test custom components with json.dumps(output) as an assertion
- After pydantic upgrades, smoke-test flows with the richest output components
When it happens
Trigger: A component returning raw objects (DB cursors, tensors, file handles, arbitrary class instances) in its Output data instead of langflow Message/Data types; outputs whose type fails pydantic-core serialization (e.g. objects with __slots__ cycles, numpy types without serializers).
Common situations: Custom components returning SDK objects directly instead of calling .data or converting to str/Message; library upgrades changing pydantic serialization strictness.
Related errors
- HTTP error! status: ${response.status}
- Could not extract class name from code
- Inputs and outputs have overlapping names: {overlap}
- {e}
- actions must be strings
AI-assisted analysis of langflow-ai/langflow@976ec789d2 (2026-08-14).
Data as JSON: /api/errors/c96a1817c4ac8f7a.
Report an issue: GitHub.