Skip to content

fix: accept numeric zero for RangeThreshold min/max (#681) - #715

Open
sankalpsthakur wants to merge 1 commit into
influxdata:masterfrom
sankalpsthakur:fix/range-threshold-zero-falsy
Open

fix: accept numeric zero for RangeThreshold min/max (#681)#715
sankalpsthakur wants to merge 1 commit into
influxdata:masterfrom
sankalpsthakur:fix/range-threshold-zero-falsy

Conversation

@sankalpsthakur

Copy link
Copy Markdown

Fixes #681

Proposed Changes

RangeThreshold.min / max (and greater/lesser value) are required floats. Validation must use identity checks against None so numeric zero (0 / 0.0) is a valid bound — not treated as “missing” the way a truthiness check (if not min) would.

This change:

  • Documents that intent on the setters (is None only; zero and within=False stay valid).
  • Adds regression tests for the issue reproduction (RangeThreshold(..., min=0, max=10, within=True)), serialization/create_check request bodies, and deserialize of min: 0.
threshold = RangeThreshold(level=CheckStatusLevel.OK, min=0, max=10, within=True)
# min stays 0; create_check JSON includes "min": 0

Checklist

  • CHANGELOG.md updated
  • Rebased/mergeable
  • A test has been added if appropriate
  • pytest tests/test_Thresholds.py::ThresholdZeroValueTest completes successfully
  • Commit messages are conventional
  • Sign CLA (if not already signed)

AI/LLM disclosure

  • AI coding tools (including Grok and/or Codex agent-assisted editing) were used to help draft or modify code and this PR description.
  • I reviewed the complete change, understand the reasoning, and ran the reported local tests before submitting.
  • This submission is original work of authorship under the project CLA / contributor terms; AI output was not pasted unreviewed.

RangeThreshold (and greater/lesser thresholds) must treat only None as
missing for required float fields. Use identity checks so 0 / 0.0 remain
valid bounds, and add regression tests covering construction,
sanitize/deserialize, and create_check request bodies with min=0.

Closes influxdata#681
@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.
✅ Project coverage is 90.41%. Comparing base (9ca599f) to head (31b0508).
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #715      +/-   ##
==========================================
+ Coverage   90.38%   90.41%   +0.02%     
==========================================
  Files          40       40              
  Lines        3546     3546              
==========================================
+ Hits         3205     3206       +1     
+ Misses        341      340       -1     

☔ 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.

RangeThreshold class pass float 0 to min or max bug

2 participants