{"record":{"id":"447ee7e891d996a8","repo":"langchain-ai/langchain","slug":"box-dimensions-should-be-1","errorCode":null,"errorMessage":"Box dimensions should be > 1","messagePattern":"Box dimensions should be > 1","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"libs/core/langchain_core/runnables/graph_ascii.py","lineNumber":174,"sourceCode":"        \"\"\"\n        for i, char in enumerate(text):\n            self.point(x + i, y, char)\n\n    def box(self, x0: int, y0: int, width: int, height: int) -> None:\n        \"\"\"Create a box on ASCII canvas.\n\n        Args:\n            x0: x coordinate of the box corner.\n            y0: y coordinate of the box corner.\n            width: box width.\n            height: box height.\n\n        Raises:\n            ValueError: if box dimensions are invalid.\n        \"\"\"\n        if width <= 1 or height <= 1:\n            msg = \"Box dimensions should be > 1\"\n            raise ValueError(msg)\n\n        width -= 1\n        height -= 1\n\n        for x in range(x0, x0 + width):\n            self.point(x, y0, \"-\")\n            self.point(x, y0 + height, \"-\")\n\n        for y in range(y0, y0 + height):\n            self.point(x0, y, \"|\")\n            self.point(x0 + width, y, \"|\")\n\n        self.point(x0, y0, \"+\")\n        self.point(x0 + width, y0, \"+\")\n        self.point(x0, y0 + height, \"+\")\n        self.point(x0 + width, y0 + height, \"+\")\n\n","sourceCodeStart":156,"sourceCodeEnd":192,"githubUrl":"https://github.com/langchain-ai/langchain/blob/e32fa9a52eab3b61ad7a45399bfde59b3e580fc4/libs/core/langchain_core/runnables/graph_ascii.py#L156-L192","documentation":"Raised by AsciiCanvas.box() when width or height is <= 1. Boxes (node frames) must span at least 2 columns and 2 lines so the border has an interior. The width/height come from the vertex view produced by the grandalf sugiyama layout, so a node whose computed w/h collapsed to 1 triggers this while drawing.","triggerScenarios":"Calling draw_ascii() on a graph where a vertex view has w <= 1 or h <= 1 (degenerate layout); direct AsciiCanvas.box(x0, y0, width, height) calls with width or height <= 1.","commonSituations":"Custom node labels or graphs that make the layout engine compute degenerate box sizes; manual canvas usage. Rare for normal chains using draw_ascii().","solutions":["If calling box() directly, pass width >= 2 and height >= 2","Shorten or simplify node names so the layout gives each node a non-degenerate size","Fall back to graph.draw_mermaid() or draw_mermaid_png() instead of draw_ascii()","Report as a langchain bug if a default graph triggers it"],"exampleFix":"// before\ncanvas.box(x, y, 1, h)\n// after\ncanvas.box(x, y, max(2, w), max(2, h))","handlingStrategy":"try-catch","validationCode":"if width < 2 or height < 2:\n    raise ValueError(\"box needs width >= 2 and height >= 2\")","typeGuard":"def valid_box(w: int, h: int) -> bool:\n    return w > 1 and h > 1","tryCatchPattern":"try:\n    graph.draw_ascii()\nexcept ValueError:\n    graph.draw_mermaid()","preventionTips":["Never call AsciiCanvas.box with width/height <= 1","Treat draw_ascii failures as layout issues and fall back to Mermaid rendering"],"tags":["graph","ascii-rendering","dimensions","valueerror"],"backgroundTag":null,"analyzedSha":"e32fa9a52eab3b61ad7a45399bfde59b3e580fc4","analyzedAt":"2026-08-14T18:42:09.092Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}