Skip to content

Refuse non-finite floats instead of publishing nan or inf - #28

Merged
dcj merged 1 commit into
mainfrom
fix/float-nonfinite
Oct 10, 2026
Merged

dcj merged 1 commit into
mainfrom
fix/float-nonfinite

Conversation

@dcj

@dcj dcj commented Oct 10, 2026

Copy link
Copy Markdown
Contributor

Fixes #27.

  • homie_format_float() and homie_format_double() return bool: false, with an empty string, for a NaN or infinity. Callers that ignore the result still compile.
  • Property::setValue(float) logs and keeps the previous value for a non-finite input.
  • test_homie_float_vectors runs the 434 float32 vectors from rust-sdk's vectors/python-sdk/float32-format.json (c31562c, generated from python-sdk 0.26.0): all pass, including the three non-finite ones that expect no payload.
  • test_property_publish checks that a NaN or infinity leaves the published value at its previous 21.4.

esp32-firmware's NodeProperty::set(float|double) needs the same guard once this is released.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Vz59zZzRfxFkWjW16egZoy

homie_format_float() and homie_format_double() wrote "nan", "inf" or
"-inf", and Property::setValue(float) published it, but the float payload
grammar has no spelling for them. The formatters now return false with an
empty string, and setValue() logs and keeps the previous value. A new
suite runs the 434 float32 vectors shared with python-sdk and rust-sdk.

Fixes #27.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vz59zZzRfxFkWjW16egZoy
@dcj
dcj merged commit 7d3a897 into main Oct 10, 2026
8 checks passed
@dcj
dcj deleted the fix/float-nonfinite branch October 10, 2026 21:18
@dcj dcj mentioned this pull request Oct 10, 2026
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.

Property::setValue(float) publishes nan/inf, which is not a valid float payload

1 participant