Repository navigation
fix: reject NaN values in score validation - #1021
Closed
Gareth.Y (linjiaye929) wants to merge 1 commit into
Closed
Gareth.Y (linjiaye929) wants to merge 1 commit into
Gareth.Y (linjiaye929) wants to merge 1 commit into
Conversation
Gareth.Y (linjiaye929)
marked this pull request as ready for review
October 31, 2026 05:42
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
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.
Summary
Reject
float("nan")at the existing score-validation boundaries. Scores are documented as numbers in[0, 1], withNonerepresenting a skipped score. The currentscore < 0 or score > 1checks reject infinities but let NaN through because both comparisons are false.Use the inclusive range predicate in
Score.__post_init__and the log-score validator. This also coversScore.from_dict/ dict-scorer normalization. Valid scores, booleans,None, and the existing error messages are unchanged.The generic JSON sanitizer intentionally converts nonfinite payload values into strings. This PR does not change that behavior: accepting NaN as a score previously allowed a scores mapping to reach that sanitizer and become
{"scores": {"accuracy": "NaN"}}, instead of being rejected as an invalid numeric score. No backend behavior is asserted.Tests
Python 3.14.7, using existing dependencies from the project's frozen test group:
test_score.pyand only the two new pure-validator test functions intest_logger.py; no logger or network request is constructed by those functions.--errors-only,git diff --check, and all seven full-repository pre-commit hooks pass.miseis unavailable in this environment, so the underlyingpre-commit run --all-filescommand was run directly with the configured tool versions.Runs used an external-socket guard and made no live Braintrust/provider calls. No dependencies or cassettes changed. The full core suite was not rerun: an earlier unrelated full-core invocation was blocked by the execution safety gate. Whole-SDK lint, static type checks, provider suites and other Python versions were not run.
AI assistance was used for analysis, implementation and local verification. No human approval or hosted CI success is claimed.