Skip to content

fix: get_benchmark_results rejects a filter on a column the chosen kind lacks - #531

Merged
yakew7 merged 1 commit into
yakew7:mainfrom
propcgamer20-png:fix/mcp-benchmark-reject-unknown-filter-column
Sep 9, 2026
Merged

fix: get_benchmark_results rejects a filter on a column the chosen kind lacks#531
yakew7 merged 1 commit into
yakew7:mainfrom
propcgamer20-png:fix/mcp-benchmark-reject-unknown-filter-column

Conversation

@propcgamer20-png

Copy link
Copy Markdown
Collaborator

Problem

_get_benchmark_results_impl (faircode/mcp_server.py) silently no-ops a filter whose column isn't in the selected kind's CSV. results_performance.csv has no protected_attribute column, so:

a = _get_benchmark_results_impl(kind="performance")
b = _get_benchmark_results_impl(kind="performance", protected_attribute="gender")
a["total_matches"], b["total_matches"], a == b
# -> 315 315 True

The caller asked for gender-specific performance numbers and got the whole unfiltered table back, with no way to tell from the response that the filter was dropped. A bogus value on a real column correctly returns total_matches: 0, so the tool already distinguishes "no match" from "filter applied" - just not "filter targets a column this kind doesn't have".

Fix

Raise ValueError when a non-None filter names a column absent from the selected kind's CSV - the same contract profile_dataset / compare_datasets use for an overrides column that isn't in the dataset:

'protected_attribute' is not a column of the 'performance' benchmark results
(available: audit, strategy, model, metric, value, ci_low, ci_high, n);
it cannot be used as a filter for this kind

audit, strategy, model, metric exist in both frozen CSVs, so the only reachable case is protected_attribute vs kind="performance". Docstring updated.

Tests

test_get_benchmark_results_performance_kind_ignores_protected_attribute_filter (which asserted the silent-ignore behavior) is replaced by test_get_benchmark_results_rejects_filter_on_column_absent_from_kind, which checks the raise for performance and that the same filter still works against fairness.

pytest tests/test_mcp_server.py -> 57 passed, 1 failed. The failure (test_get_explainer_returns_content_and_metadata) is pre-existing on main on this platform (a \ vs / path check in _get_explainer_impl) and unrelated to this change. ruff clean.

Closes #512

🤖 Generated with Claude Code

_get_benchmark_results_impl silently dropped a filter that named a column
absent from the selected kind's CSV (results_performance.csv has no
protected_attribute column), so `kind="performance", protected_attribute=
"gender"` returned the entire unfiltered 315-row table with nothing in
the response signalling the filter was ignored.

It now raises ValueError in that case, consistent with
profile_dataset/compare_datasets rejecting an `overrides` column that
isn't in the dataset. The only reachable case is protected_attribute
against kind="performance"; audit/strategy/model/metric exist in both
frozen CSVs.

Closes yakew7#512

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@vercel

vercel Bot commented Sep 9, 2026

Copy link
Copy Markdown
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.

@github-actions

github-actions Bot commented Sep 9, 2026

Copy link
Copy Markdown

@yakew7 @ahmdkaml - new PR touching a path you own, please review.

@yakew7
yakew7 merged commit 53531cc into yakew7:main Sep 9, 2026
17 of 18 checks passed
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.

get_benchmark_results silently no-ops a filter on a column the chosen kind doesn't have

2 participants