Skip to content

FIX: Keep valid scorer metrics accessible after malformed registry records - #4853

Open
biefan (biefan) wants to merge 1 commit into
microsoft:mainfrom
biefan:fix/skip-invalid-scorer-registry-records
Open

biefan (biefan) wants to merge 1 commit into
microsoft:mainfrom
biefan:fix/skip-invalid-scorer-registry-records

Conversation

@biefan

Copy link
Copy Markdown
Contributor

Description

Closes #4852.

A single JSONL record containing null could make listing scorer metrics or looking up a cached result raise AttributeError. With that line prepended to the bundled objective registry, both calls now succeed and all 34 original records remain available.

  • Skip non-object records and non-object metrics payloads during reads, logging the file and line number.
  • Continue a hash lookup past a matching record whose metrics cannot be constructed, so a later usable match can still be returned.
  • Exercise both public read APIs with a malformed record followed by a valid result and check that the file stays byte-for-byte intact.

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

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 keeping valid scorer metrics accessible despite malformed registry records.

No open issues 🎉

What changed in this PR

Fixes #4852 by keeping valid scorer metrics accessible when registry files contain malformed records.

Changes:

  • Skip non-object records and non-object metrics payloads with diagnostic logging.
  • Continue hash lookups past unusable matches.
  • Test both public read APIs and verify registry files remain unchanged.
File Description
tests/​unit/​score/​test_scorer_metrics_io.py Tests malformed-record handling and byte-for-byte file preservation.
pyrit/​score/​scorer_evaluation/​scorer_metrics_io.py Filters invalid records and continues lookups after metrics construction failures.

Review effort: Balanced

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: A malformed scorer metrics record prevents reads of valid registry entries

2 participants