langchain-ai/langchain · error · ValueError
Invalid edge coordinates: start_x={start_x}, start_y={start_
Error message
Invalid edge coordinates: start_x={start_x}, start_y={start_y}, end_x={end_x}, end_y={end_y} What it means
Before drawing each edge segment, draw_ascii() subtracts the graph-wide minimum x/y offsets and rounds; if any resulting coordinate is negative it raises this ValueError with the offending coordinates. Negative values mean the layout placed part of an edge left/above the minimum corner, i.e. inconsistent geometry or a rounding artifact.
Source
Thrown at libs/core/langchain_core/runnables/graph_ascii.py:348
raise ValueError(msg)
for index in range(1, len(edge.view.pts)):
start = edge.view.pts[index - 1]
end = edge.view.pts[index]
start_x = round(start[0] - minx)
start_y = round(start[1] - miny)
end_x = round(end[0] - minx)
end_y = round(end[1] - miny)
if start_x < 0 or start_y < 0 or end_x < 0 or end_y < 0:
msg = (
"Invalid edge coordinates: "
f"start_x={start_x}, "
f"start_y={start_y}, "
f"end_x={end_x}, "
f"end_y={end_y}"
)
raise ValueError(msg)
canvas.line(start_x, start_y, end_x, end_y, "." if edge.data else "*")
for vertex in sug.g.sV:
# NOTE: moving boxes w/2 to the left
x = vertex.view.xy[0] - vertex.view.w / 2.0
y = vertex.view.xy[1]
canvas.box(
round(x - minx),
round(y - miny),
vertex.view.w,
vertex.view.h,
)
canvas.text(round(x - minx) + 1, round(y - miny) + 1, vertex.data)
return canvas.draw()View on GitHub (pinned to e32fa9a52e)
Solutions
- Retry with draw_mermaid() which does not use this code path
- Upgrade langchain-core and grandalf (layout rounding fixes land over time)
- Slightly change the graph (node labels/edges) to shift layout coordinates off the boundary
- Report as a bug with a minimal reproducer
Defensive patterns
Strategy: try-catch
Try / catch
try:
graph.draw_ascii()
except ValueError as e:
if "Invalid edge coordinates" in str(e):
art = graph.draw_mermaid() Prevention
- Treat ASCII rendering as best-effort; keep a Mermaid fallback
- Report reproducible layout rounding bugs upstream with the graph structure
When it happens
Trigger: graph.draw_ascii() when round(point - minx/miny) goes negative for an edge point — floating-point rounding right at a boundary or inconsistent layout minima.
Common situations: Edge case in the grandalf layout for particular graph shapes; not user-controllable via public API. Rare.
Related errors
- Not enough points to draw an edge
- y should be >= 0 and < number of lines
- Box dimensions should be > 1
- Install grandalf to draw graphs: `pip install grandalf`.
- Found duplicate subgraph '{subgraph}' -- this likely means t
AI-assisted analysis of langchain-ai/langchain@e32fa9a52e (2026-08-14).
Data as JSON: /api/errors/e8e73013391b229a.
Report an issue: GitHub.