{"record":{"id":"ddfd8469aafb454d","repo":"langchain-ai/langchain","slug":"canvas-dimensions-should-be-1","errorCode":null,"errorMessage":"Canvas dimensions should be > 1","messagePattern":"Canvas dimensions should be > 1","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"warning","filePath":"libs/core/langchain_core/runnables/graph_ascii.py","lineNumber":74,"sourceCode":"\nclass AsciiCanvas:\n    \"\"\"Class for drawing in ASCII.\"\"\"\n\n    TIMEOUT = 10\n\n    def __init__(self, cols: int, lines: int) -> None:\n        \"\"\"Create an ASCII canvas.\n\n        Args:\n            cols: number of columns in the canvas. Should be `> 1`.\n            lines: number of lines in the canvas. Should be `> 1`.\n\n        Raises:\n            ValueError: if canvas dimensions are invalid.\n        \"\"\"\n        if cols <= 1 or lines <= 1:\n            msg = \"Canvas dimensions should be > 1\"\n            raise ValueError(msg)\n\n        self.cols = cols\n        self.lines = lines\n\n        self.canvas = [[\" \"] * cols for line in range(lines)]\n\n    def draw(self) -> str:\n        \"\"\"Draws ASCII canvas on the screen.\n\n        Returns:\n            The ASCII canvas string.\n        \"\"\"\n        lines = map(\"\".join, self.canvas)\n        return os.linesep.join(lines)\n\n    def point(self, x: int, y: int, char: str) -> None:\n        \"\"\"Create a point on ASCII canvas.\n","sourceCodeStart":56,"sourceCodeEnd":92,"githubUrl":"https://github.com/langchain-ai/langchain/blob/e32fa9a52eab3b61ad7a45399bfde59b3e580fc4/libs/core/langchain_core/runnables/graph_ascii.py#L56-L92","documentation":"`AsciiCanvas.__init__` (used by `DrawGraph` to render runnable graphs as ASCII art) requires both `cols` and `lines` to be greater than 1, otherwise there is no drawable area. Violating this raises `ValueError: Canvas dimensions should be > 1`.","triggerScenarios":"Instantiating `AsciiCanvas(0, 10)`, `AsciiCanvas(80, 1)`, or with negative values; calling `AsciiCanvas`-based rendering with dimensions computed from graph size (e.g. `node_degree * scale`) where the computation yields 0/1 for tiny graphs.","commonSituations":"Auto-sizing logic that scales canvas size by the number of nodes/edges and collapses to <=1 for a minimal graph (single node, no edges); passing terminal width from a CI environment where `shutil.get_terminal_size()` reports tiny dimensions; customizing `DrawGraph` node size constants to 0.","solutions":["Clamp dimensions to a minimum: `max(cols, 2)` and `max(lines, 2)` before constructing.","Use the default `DrawGraph(graph).draw()` path instead of constructing `AsciiCanvas` with computed sizes.","If customizing `DrawGraph`, keep `node_size` and the derived canvas math well above 1."],"exampleFix":"# before\ncanvas = AsciiCanvas(int(width * ratio), int(height * ratio))  # can hit 1\n\n# after\ncanvas = AsciiCanvas(max(int(width * ratio), 2), max(int(height * ratio), 2))","handlingStrategy":"validation","validationCode":"cols, lines = max(cols, 2), max(lines, 2)\ncanvas = AsciiCanvas(cols, lines)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Clamp computed canvas dimensions to >= 2.","Use the default DrawGraph(graph).draw() instead of manual sizing.","Test auto-sizing code against the smallest possible graph."],"tags":["graph","ascii-art","value-error","visualization","langchain-core"],"backgroundTag":null,"analyzedSha":"e32fa9a52eab3b61ad7a45399bfde59b3e580fc4","analyzedAt":"2026-08-14T18:42:09.092Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}