fix: reject out-of-range profiler tunables instead of self-contradicting output - #533
Merged
yakew7 merged 1 commit intoSep 9, 2026
Conversation
min_share / intersection_floor / missing_flag / reference_flag were accepted as any float, and imbalance_flag / min_group_size as any number, with no range check anywhere in the CLI -> _build_opts -> _resolve_opts chain. min_share=1.5 (a percentage/fraction typo) was silently accepted: every group got flagged "under-represented" in flags while overall_score/grade stayed 100/"A" - the two halves of the same report contradicting each other with no error. _resolve_opts (and its JS mirror resolveOpts) now validate: - min_share, intersection_floor, missing_flag, reference_flag in [0, 1] - imbalance_flag >= 1 - min_group_size >= 1 raising ValueError, which the CLI already renders as "error: ..." (exit 2) and the MCP server wraps as a ToolError. Covers profile_dataset, compare_datasets, `faircode profile`, and `faircode compare`. Closes yakew7#511 Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Contributor
|
@propcgamer20-png is attempting to deploy a commit to the yashkewlani2020-gmailcom's projects Team on Vercel. A member of the Team first needs to authorize it. |
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.
Problem
min_share/intersection_floor/imbalance_flag/missing_flagare accepted as plain floats with no range validation anywhere in the call chain (cli.pyargparse ->mcp_server._build_opts->profiler._resolve_opts).min_share=1.5can't be a share, yet every group is flagged under-represented while the score stays a perfect "A" - the two halves of the same report directly contradict each other. A15-instead-of-0.15typo produces exactly this.Fix
_resolve_opts(Python) andresolveOpts(JS, for parity) now validate on everyprofile()call:min_share,intersection_floor,missing_flag,reference_flag[0, 1]imbalance_flag>= 1(it's amax_share / min_shareratio)min_group_size>= 1Out-of-range values raise
ValueError. The CLI already renders that aserror: ...(exit 2); the MCPbuild_server()wrappers already translate it toToolError. Soprofile_dataset,compare_datasets,faircode profile, andfaircode compareare all covered through the one chokepoint. Defaults are unchanged and still valid.Tests
test_out_of_range_tunables_raise_instead_of_contradicting_themselves(parametrized,test_profiler.py)test_profile_rejects_out_of_range_min_share(test_cli.py, argparse/exit-code path)test_python_js_reject_out_of_range_min_share_parity(test_js_parity.py, both engines reject)pyteston the touched suites -> 186 passed, 2 failed. Both failures (test_get_explainer_returns_content_and_metadata,test_python_js_profiler_parity_sniffs_quoted_newlines) are pre-existing onmainon this platform and unrelated.ruffclean.Closes #511
🤖 Generated with Claude Code