Repository navigation
fix(comparators): raise ValueError for out-of-range or non-string config (#663) - #667
Merged
Merged
Conversation
…rror - math.isfinite() converts an int to float, so 10**400, 2**1024 or -10**400 raised OverflowError instead of the documented ValueError - convert once under try/except OverflowError, then check the float, the same way _normalize_point already handles coordinates - pin that an int max_distance is stored as a float
- the dict membership check raised TypeError for an unhashable value such as a list; the docstring promises ValueError for any invalid angle_unit - the changelog entry for the unreleased AngleComparator now says so
Security Scan ResultsASH Security Scan Report
Scan Metadata
SummaryScanner ResultsThe table below shows findings by scanner, with status based on severity thresholds and dependencies:
Report generated by Automated Security Helper (ASH) at 2026-11-28T04:48:37+00:00 |
vawsgit
approved these changes
Nov 28, 2026
vawsgit
left a comment
Contributor
There was a problem hiding this comment.
✅ LGTM!
I tested head b10eb20 against origin/dev (0a4820f). origin/dev is also the merge base, so the branch is current.
What I checked:
- The cases from #663. All five now raise
ValueError:max_distance=10**400,2**1024andinf, andangle_unit=["degrees"]and"deg". Ondev, the two big ints raisedOverflowErrorand the list raisedTypeError. - Values that worked before still work. I ran 32 inputs through both constructors and through
create_comparatorondevand on this head, then diffed the output. Only the intended cases changed: big positive and negative ints,2**1024-1, and a list or dictangle_unit.- Still accepted:
int,float,np.float64, int and float subclasses,2**1023,5e-324,"radians", a str-Enum member,np.str_. - Still rejected:
True,None,"10", NaN,"Degrees",np.int64,Fraction,Decimal.
- Still accepted:
- Config and registry. A 400-digit integer loaded with
json.loadsnow raisesValueError. The field converter wraps it the same way it wraps"deg".configstill round-trips:{'max_distance': 5.0}. - Tests. The two changed test files pass (65 tests). The full suite with
-n autogives 6756 passed, 13 skipped and 1 xfailed, which matches the PR body. Ruff and CI are clean. - Mutation tests. Every new test fails when I break the fix it covers.
- Restoring
dev's two source files fails 4 tests:10**400,2**1024,-10**400and the listangle_unit. - Removing only
except OverflowErrorfails the 3 big-int tests. - Storing the raw
max_distanceinstead of the float failstest_int_max_distance_is_stored_as_float.
- Restoring
- Linked issue. #663 asks only for
max_distanceandangle_unitto raiseValueError, and this PR does both, soFixes #663is correct. The CHANGELOG entry follows the repo's format.
Optional, not blocking:
point_distance.py#L80-L82puts{max_distance!r}in the message. For an int of more than 4300 digits, building that repr fails, soPointDistanceComparator(max_distance=10**5000)showsValueError: Exceeds the limit (4300 digits) for integer string conversion...instead of your message. The error is still aValueError, so the contract this PR promises holds.FuzzyComparatorhas the same bug in code this PR does not touch:FuzzyComparator(method=["ratio"])raisesTypeError: unhashable type: 'list'. #663 does not cover it, so it could be a follow-up issue.
4 of 7 tasks
3 of 5 tasks
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.
tl;dr for humans
Fixes #663.
PointDistanceComparator(max_distance=10**400)raisedOverflowErrorandAngleComparator(angle_unit=["degrees"])raisedTypeError. Both now raise the documentedValueError.for agents
ValueError.point_distance.py: convertmax_distanceto float once; an int beyond float range maps toinfand fails the same finite check. The stored value is always a float.angle.py: reject a non-stringangle_unitbefore the lookup.fix(comparators): reject an out-of-range int max_distance with ValueErrorfix(comparators): reject a non-string angle_unit with ValueError(with its CHANGELOG line)dev(4 failed:10**400,2**1024,-10**400, listangle_unit) and pass with the fix; a test pins that an intmax_distanceis stored as a float.-n auto: 6756 passed, 13 skipped, 1 xfailed.ruff checkclean.tests/integrations(Strands Evals contract): 641 passed, 1 skipped.