Skip to content

fix: reject non-finite watchdog thresholds from the environment - #86

Open
tabedzki wants to merge 1 commit into
m-beau:devfrom
tabedzki:tabedzki/fix/watchdog-nonfinite-env
Open

tabedzki wants to merge 1 commit into
m-beau:devfrom
tabedzki:tabedzki/fix/watchdog-nonfinite-env

Conversation

@tabedzki

Copy link
Copy Markdown
Collaborator

🤖 AI text below 🤖

Problem

The watchdog reads its thresholds with float(), which also accepts nan, inf and -inf:

Setting Effect before this fix
PIXELMAP_STALL_WARN_S=nan the stall comparison misbehaves and can report a stall on every check, even while the loop is healthy
PIXELMAP_STALL_WARN_S=inf stall warnings are silently off
PIXELMAP_RSS_WARN_MB=nan / inf memory warnings are silently off

A typo or a templated value can produce these, and nothing in the log says the watchdog has been neutered.

Fix

_env_float in pixelmap/gui/watchdog.py now treats non-finite values like any other non-number: it logs the existing warning and uses the default. Finite zero and negative values are still returned unchanged, because they deliberately switch a check off. Blank or unset values stay silent and use the default, as before.

This came out of a review of the project's environment-variable parsers during PR #85. Merging those parsers into one helper was considered and rejected: they follow four different rules, so the shared helper would add code rather than remove it.

Tests

Written first; the six non-finite cases failed before the fix.

  • nan, NaN, inf, -inf, Infinity and padded inf all fall back to the default and log a warning naming the variable.
  • Padded, negative, -0 and exponent values are still accepted.
  • Unset, empty and whitespace-only values return the default without a warning.

Full suite: 941 passed, 1 xfailed. ruff check is clean on the changed files.

🤖 Generated with Claude Code

float() accepts "nan", "inf" and "-inf", so PIXELMAP_STALL_WARN_S and
PIXELMAP_RSS_WARN_MB took them as thresholds. NaN breaks every stall
comparison, and +inf (or inf/nan for the RSS limit) silently disables
the check. Treat them like any other non-number: warn and use the
default. Finite zero and negatives are still returned as-is, since
they deliberately switch a check off.

Assisted-by: ClaudeCode:claude-opus-5-5
@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (dev@206230c). Learn more about missing BASE report.
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@          Coverage Diff           @@
##             dev      #86   +/-   ##
======================================
  Coverage       ?   83.25%           
======================================
  Files          ?       21           
  Lines          ?     3410           
  Branches       ?        0           
======================================
  Hits           ?     2839           
  Misses         ?      571           
  Partials       ?        0           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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