Skip to content

fix(shapes,colors): guard zero-length dashed line; warn on unresolved colors#29

Merged
g4bri3lDev merged 1 commit into
OpenDisplay:mainfrom
balloob:fix/shapes-and-colors
Jul 6, 2026
Merged

fix(shapes,colors): guard zero-length dashed line; warn on unresolved colors#29
g4bri3lDev merged 1 commit into
OpenDisplay:mainfrom
balloob:fix/shapes-and-colors

Conversation

@balloob

@balloob balloob commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

Summary

Two small robustness fixes: a crash in dashed-line drawing and silent white fallbacks in the color resolver.

Findings addressed

  • A4 — ZeroDivisionError on a zero-length dashed line. draw_dashed_line computed step_x = dx / line_length without checking for line_length == 0. A line with start == end — easily produced from templated coordinates, e.g. {type: line, x_start: 50, x_end: 50, dashed: true} (equal y defaults) — crashed. debug_grid uses the same helper. It now draws the degenerate point and returns.
  • A11 — silent white fallback for bad colors. An unknown name ("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

… 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
@balloob balloob requested a review from g4bri3lDev as a code owner July 4, 2026 07:22
@codecov

codecov Bot commented Jul 4, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 94.44444% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/odl_renderer/colors.py 92.85% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@g4bri3lDev g4bri3lDev merged commit 7bfe12b into OpenDisplay:main Jul 6, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants