Skip to content

fix(core): reject non-finite numeric inputs in wind definitions - #166

Merged
CameronBrooks11 merged 1 commit into
mainfrom
fix/reject-non-finite-inputs
Jun 25, 2026
Merged

CameronBrooks11 merged 1 commit into
mainfrom
fix/reject-non-finite-inputs

Conversation

@CameronBrooks11

Copy link
Copy Markdown
Member

Bug B1 from the latent-bug audit (verified by execution).

Problem

json.loads accepts the NaN/Infinity literals, and BaseFiberPathModel did not set allow_inf_nan=False, so non-finite floats passed schema validation:

  • A NaN mandrelRotation (skip layer) serialized into generated G-code as a literal Anan axis word, and total_time_s became NaN.
  • An Infinity diameter/windLength overflowed math.ceil(...) in the planner → uncaught OverflowError → HTTP 500 (API) / raw traceback (CLI).

Fix

Set allow_inf_nan=False on the shared base model — one change guards every float field. load_wind_definition then surfaces it as the normal WindFileError.

TDD

  • RED: added test_load_wind_definition_rejects_infinite_diameter and ..._rejects_nan_mandrel_rotation — both failed ("DID NOT RAISE") before the fix.
  • GREEN: pass after the config change. Full suite 121 passed (+2), ruff/format/mypy clean.

JSON permits the NaN/Infinity literals and BaseFiberPathModel did not set
allow_inf_nan=False, so non-finite floats passed schema validation. A NaN
mandrelRotation then serialized into G-code as a literal 'Anan' axis word
and made total_time NaN; an Infinity diameter/length overflowed math.ceil in
the planner, raising an uncaught OverflowError surfaced as an HTTP 500 (API)
or raw traceback (CLI).

Set allow_inf_nan=False on the shared base model so every float field rejects
NaN/Infinity at validation; load_wind_definition surfaces it as WindFileError.
Adds regression tests for an infinite diameter and a NaN mandrel rotation.
@CameronBrooks11
CameronBrooks11 merged commit 6e9a96b into main Jun 25, 2026
18 checks passed
@CameronBrooks11
CameronBrooks11 deleted the fix/reject-non-finite-inputs branch June 25, 2026 21:03
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.

1 participant