fix(shapes,colors): guard zero-length dashed line; warn on unresolved colors#29
Merged
Merged
Conversation
… colors - A4: draw_dashed_line divided by the line length without a zero check, so a zero-length line (start == end, trivially produced by templated coordinates, and also reachable via debug_grid) raised ZeroDivisionError. It now draws the single point and returns. - A11: unknown color names and malformed hex previously fell back to white silently — invisible on the default white background with no diagnostic. The resolver now logs a warning the first time each unresolved token is seen (once per token, so a repeatedly-rendering dashboard doesn't spam the log). Adds regression tests for the zero-length dashed line and the warn-once behavior. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UVpLN4Rzdv7y3ud7QzutVJ
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two small robustness fixes: a crash in dashed-line drawing and silent white fallbacks in the color resolver.
Findings addressed
ZeroDivisionErroron a zero-length dashed line.draw_dashed_linecomputedstep_x = dx / line_lengthwithout checking forline_length == 0. A line withstart == end— easily produced from templated coordinates, e.g.{type: line, x_start: 50, x_end: 50, dashed: true}(equal y defaults) — crashed.debug_griduses the same helper. It now draws the degenerate point and returns."balck") or malformed hex ("#12345") resolved to white, which is invisible on the default white background and logged nothing. The resolver now emits a warning the first time each unresolved token is encountered, deduplicated per token so a dashboard re-rendering every update logs once rather than every frame. Behavior (white fallback) is unchanged; this only adds the diagnostic.Tests
Adds a regression test for the zero-length dashed line and tests that an unknown name / malformed hex warns exactly once while a known color stays silent.
🤖 Generated with Claude Code