Skip to content

FIX: Reject surplus CSV fields that shift evaluation responses - #4851

Open
biefan (biefan) wants to merge 2 commits into
microsoft:mainfrom
biefan:fix/reject-shifted-evaluation-csv
Open

biefan (biefan) wants to merge 2 commits into
microsoft:mainfrom
biefan:fix/reject-shifted-evaluation-csv

Conversation

@biefan

Copy link
Copy Markdown
Contributor

Description

Closes #4850.

A human-labeled CSV whose first data record has more fields than its header can make pandas infer an index from the leading fields. For example, Good morning, Alice,greeting,1 under a three-column header used to load as the response Alice with a valid positive label.

The loader now rejects an inferred index before it extracts responses and labels. The error names the CSV and explains how to quote a comma inside a field. Regression tests exercise objective and harm datasets with one or two excess fields, and verify that a correctly quoted response containing both a comma and a newline round-trips intact.

Copilot AI balanced review requested due to automatic review settings December 5, 2026 00:44

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues remain for the change that rejects malformed human-labeled CSV records.

No open issues 🎉

What changed in this PR

Fixes #4850 by rejecting malformed human-labeled CSV files that cause pandas to silently shift evaluation responses and labels.

Changes:

  • Rejects inferred indexes with an error identifying the CSV and explaining comma quoting.
  • Adds regression coverage for surplus fields in objective and harm datasets, plus correctly quoted multiline responses.
File Description
tests/​unit/​score/​test_human_labeled_dataset.py Tests malformed records and preservation of quoted responses.
pyrit/​score/​scorer_evaluation/​human_labeled_dataset.py Rejects inferred indexes before extracting evaluation data.

Review effort: Balanced

@biefan

Copy link
Copy Markdown
Contributor Author

Fixed the Windows regression test in 7baf2fc. The Windows failure log showed that the CSV writer produced CRLF inside the quoted response and the loader correctly preserved it, while the assertion expected LF. The test now writes LF and CRLF explicitly and checks that each survives the round trip. The dataset and evaluator suites passed locally on Python 3.13 and 3.14 (350 tests on each).

@biefan

Copy link
Copy Markdown
Contributor Author

The Windows matrix passed on 7baf2fc. Could a maintainer rerun just the macOS / Python 3.13 / dev_all job? It is the only failed check. I tried the single-job rerun endpoint and received HTTP 403.

The log reports:

FAILED tests/unit/score/regex/test_markdown_injection.py::test_md_injection_scales_on_unpaired_shortcut_labels[image-and-definition-lines] - Failed: Timeout (>10.0s) from pytest-timeout.

This PR changes the evaluation CSV loader and its tests. The timeout occurred in the Markdown scaling test covered by #4842.

This branch has not been deployed

No deployments
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.

BUG: Extra CSV fields silently truncate responses in human-labeled evaluations

2 participants