Skip to content

fix(benchmark): name the manifest once in validation errors - #1181

Merged
yakew7 merged 1 commit into
yakew7:mainfrom
bfs2021:fix/manifest-path-once
Oct 25, 2026
Merged

yakew7 merged 1 commit into
yakew7:mainfrom
bfs2021:fix/manifest-path-once

Conversation

@bfs2021

@bfs2021 bfs2021 commented Oct 25, 2026

Copy link
Copy Markdown
Contributor

Problem

A manifest validation error prints the manifest path twice:

$ python3 -m faircode benchmark m2.yaml
error: m2.yaml: m2.yaml: protected_attributes must have at least one entry

Fixes #1179.

Root cause

Manifest.from_dict raises f"{manifest_path}: protected_attributes must have at least one entry", and run_benchmark wraps every ValueError from its per-manifest try with f"{path}: {exc}" so that errors without context (bad YAML, a missing key, a degenerate dataset) still name the manifest. For validation errors that already carry the path, the prefix lands twice.

Fix

run_benchmark now adds the path only when the error message does not already start with it. The path is still printed once for every failure, and Manifest.from_dict keeps its own context for direct/library callers such as load_audit.

Testing

  • New test_run_benchmark_names_the_manifest_once_in_validation_errors: asserts the message contains the manifest path exactly once (fails on the old code with 2 occurrences).
  • python -m faircode benchmark m2.yaml now prints error: m2.yaml: protected_attributes must have at least one entry.
  • python -m pytest tests/test_benchmark.py -q -k "validation_errors" → passes; ruff check → clean. The three ..._with_manifest_path tests fail on this Windows box both before and after the change because pytest.raises(match=...) compiles the backslashed path as a regex (incomplete escape \U) — verified by stashing the change.

)

Manifest.from_dict already prefixes its own errors with the manifest path,
so run_benchmark's wrapper produced 'm2.yaml: m2.yaml: ...' for validation
failures. Only add the path when the error does not already carry it.
@vercel

vercel Bot commented Oct 25, 2026

Copy link
Copy Markdown
Contributor

@bfs2021 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

Copy link
Copy Markdown

Hey @bfs2021, your first PR on Fair Code, that's awesome, thank you.

This project is about making AI more accountable, and contributions like yours are what keep that work going. We'll review your changes shortly.

If you haven't already, give the contributing guide a quick read: it covers how audits are structured and what we look for in a review.

And if you're finding Fair Code useful or interesting, a star on the repo genuinely helps more people find it - no pressure, just appreciated.

@github-actions

Copy link
Copy Markdown

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

@yakew7
yakew7 merged commit 000de7c into yakew7:main Oct 25, 2026
18 of 19 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.

A manifest validation error prints the file name twice

2 participants