{"record":{"id":"d4960b619b3a7178","repo":"langchain-ai/langchain","slug":"y-should-be-0-and-number-of-lines","errorCode":null,"errorMessage":"y should be >= 0 and < number of lines","messagePattern":"y should be >= 0 and < number of lines","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"libs/core/langchain_core/runnables/graph_ascii.py","lineNumber":113,"sourceCode":"                the canvas.\n            y: y coordinate. Should be `>= 0` an `<` number of lines in the\n                canvas.\n            char: character to place in the specified point on the\n                canvas.\n\n        Raises:\n            ValueError: if char is not a single character or if\n                coordinates are out of bounds.\n        \"\"\"\n        if len(char) != 1:\n            msg = \"char should be a single character\"\n            raise ValueError(msg)\n        if x >= self.cols or x < 0:\n            msg = \"x should be >= 0 and < number of columns\"\n            raise ValueError(msg)\n        if y >= self.lines or y < 0:\n            msg = \"y should be >= 0 and < number of lines\"\n            raise ValueError(msg)\n\n        self.canvas[y][x] = char\n\n    def line(self, x0: int, y0: int, x1: int, y1: int, char: str) -> None:\n        \"\"\"Create a line on ASCII canvas.\n\n        Args:\n            x0: x coordinate where the line should start.\n            y0: y coordinate where the line should start.\n            x1: x coordinate where the line should end.\n            y1: y coordinate where the line should end.\n            char: character to draw the line with.\n        \"\"\"\n        if x0 > x1:\n            x1, x0 = x0, x1\n            y1, y0 = y0, y1\n\n        dx = x1 - x0","sourceCodeStart":95,"sourceCodeEnd":131,"githubUrl":"https://github.com/langchain-ai/langchain/blob/e32fa9a52eab3b61ad7a45399bfde59b3e580fc4/libs/core/langchain_core/runnables/graph_ascii.py#L95-L131","documentation":"Raised by AsciiCanvas.point() when the y coordinate is negative or >= the number of canvas lines. The ASCII canvas is a fixed-size 2D grid sized from the graph layout; any write outside it is rejected. In practice this is an internal guard hit while rendering a graph with draw_ascii(), usually because the computed layout produced a point outside the canvas bounds.","triggerScenarios":"Calling chain.get_graph().draw_ascii() (or graph_ascii.draw_ascii) on a graph whose sugiyama layout computes y coordinates that fall outside the canvas lines dimension; direct AsciiCanvas users calling point(x, y, char) with y >= canvas.lines or y < 0.","commonSituations":"Very wide or deeply nested graphs, graphs with long node labels, edge cases in grandalf layout rounding, or direct low-level canvas misuse. Most user code never touches AsciiCanvas directly, so hitting this means the layout step produced out-of-bounds geometry.","solutions":["If calling point() directly, fix the y coordinate to satisfy 0 <= y < canvas.lines (check canvas.lines first)","Shorten node names/labels so the computed layout fits the canvas","Fall back to a different renderer, e.g. graph.draw_mermaid() or draw_mermaid_png(), which do not use the ASCII canvas","If it reproduces on a plain graph with default settings, report it as a bug to langchain with a minimal reproducer"],"exampleFix":"// before\ncanvas.point(x, y, \"*\") // y from untrusted math\n// after\nif 0 <= y < canvas.lines and 0 <= x < canvas.cols:\n    canvas.point(x, y, \"*\")","handlingStrategy":"try-catch","validationCode":"// n/a: coordinates are computed internally by the layout; guard at the call level","typeGuard":"def in_bounds(canvas: AsciiCanvas, x: int, y: int) -> bool:\n    return 0 <= x < canvas.cols and 0 <= y < canvas.lines","tryCatchPattern":"try:\n    art = graph.draw_ascii()\nexcept ValueError as e:\n    art = graph.draw_mermaid()  # textual fallback","preventionTips":["Prefer draw_mermaid() when rendering user-supplied or dynamically built graphs","Keep node labels short so the ASCII layout stays well within canvas bounds"],"tags":["graph","ascii-rendering","coordinates","valueerror"],"backgroundTag":null,"analyzedSha":"e32fa9a52eab3b61ad7a45399bfde59b3e580fc4","analyzedAt":"2026-08-14T18:42:09.092Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}