langflow-ai/langflow · error · HTTPException

Error building Component

Error message

Error building Component

What it means

Raised as HTTP 500 with the static detail 'Error building Component' when constructing the StreamingResponse around _stream_vertex raises synchronously (before streaming begins). The static message is deliberate: at this point no component error context is available, and the real cause is logged via the exception chain (`from exc`) and server logs.

Source

Thrown at src/backend/base/langflow/api/v1/chat.py:768

        flow = (await session.exec(stmt)).first()
    if not flow:
        raise HTTPException(status_code=404, detail=f"Flow with id {flow_id} not found")
    await ensure_flow_permission(
        current_user,
        FlowAction.EXECUTE,
        flow_id=flow_id,
        flow_user_id=flow.user_id,
        workspace_id=flow.workspace_id,
        folder_id=flow.folder_id,
    )

    try:
        return StreamingResponse(
            _stream_vertex(str(flow_id), vertex_id, get_chat_service()),
            media_type="text/event-stream",
        )
    except Exception as exc:
        raise HTTPException(status_code=500, detail="Error building Component") from exc


async def build_flow_and_stream(flow_id, inputs, background_tasks, current_user):
    queue_service = get_queue_service()
    build_response = await build_flow(
        flow_id=flow_id,
        inputs=inputs,
        background_tasks=background_tasks,
        current_user=current_user,
        queue_service=queue_service,
        event_delivery=EventDeliveryType.STREAMING,
    )
    job_id = build_response["job_id"]
    return await get_flow_events_response(
        job_id=job_id,
        queue_service=queue_service,
        event_delivery=EventDeliveryType.STREAMING,
    )

View on GitHub (pinned to 976ec789d2)

Solutions

  1. Check the server log for the chained `from exc` traceback — the detail string will not tell you the cause.
  2. Retry after re-building the flow (POST /build/{flow_id}) to reset chat service cache state.
  3. If reproducible, capture the traceback and report it upstream; the static message hides the root cause from the client.
  4. Verify no custom middleware interferes with text/event-stream responses.
Defensive patterns

Strategy: try-catch

Try / catch

try:
    return StreamingResponse(_stream_vertex(...), media_type="text/event-stream")
except Exception as exc:
    logger.exception("Error building Component")
    raise HTTPException(status_code=500, detail="Error building Component") from exc

Prevention

When it happens

Trigger: Calling the stream-vertex endpoint when StreamingResponse(...) setup fails — e.g. the generator object cannot be created because chat service state is broken, or an exception escapes _stream_vertex's outer generator frame immediately.

Common situations: Server-side misconfiguration of the chat service singleton; rare internal-state corruption after cache invalidation; middleware that inspects the response body of a streaming response and fails.

Related errors


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