Repository navigation
fix(core): reject non-finite numeric inputs in wind definitions - #166
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug B1 from the latent-bug audit (verified by execution).
Problem
json.loadsaccepts theNaN/Infinityliterals, andBaseFiberPathModeldid not setallow_inf_nan=False, so non-finite floats passed schema validation:NaNmandrelRotation(skip layer) serialized into generated G-code as a literalAnanaxis word, andtotal_time_sbecameNaN.Infinitydiameter/windLengthoverflowedmath.ceil(...)in the planner → uncaughtOverflowError→ HTTP 500 (API) / raw traceback (CLI).Fix
Set
allow_inf_nan=Falseon the shared base model — one change guards every float field.load_wind_definitionthen surfaces it as the normalWindFileError.TDD
test_load_wind_definition_rejects_infinite_diameterand..._rejects_nan_mandrel_rotation— both failed ("DID NOT RAISE") before the fix.