Skip to content

FIX Reject explicit empty objectives in batch scoring#1503

Merged
romanlutz merged 2 commits intomicrosoft:mainfrom
biefan:reject-empty-batch-objectives
Apr 24, 2026
Merged

FIX Reject explicit empty objectives in batch scoring#1503
romanlutz merged 2 commits intomicrosoft:mainfrom
biefan:reject-empty-batch-objectives

Conversation

@biefan
Copy link
Copy Markdown
Contributor

@biefan biefan commented Mar 17, 2026

Summary

  • distinguish omitted objectives from an explicit empty sequence in batch scoring entry points
  • reject objectives=[] when scoring non-empty prompt or image batches
  • add regression coverage for both prompt and image batch scoring paths

Problem

score_prompts_batch_async() treats objectives=[] the same as objectives=None, replacing it with default empty-string objectives and continuing into the scoring pipeline. score_image_batch_async() has the same issue. This skips the documented length validation and can trigger unrelated downstream failures instead of failing fast.

Validation

  • .venv/bin/pytest tests/unit/score -q
  • .venv/bin/ruff check pyrit/score/scorer.py tests/unit/score/test_scorer.py

- Update Raises docstring in score_prompts_batch_async to reflect the
  actual validation logic (length mismatch, not 'is empty')
- Add regression test confirming objectives=None defaults to empty
  strings in score_prompts_batch_async
- Add regression test confirming objectives=None omits objectives
  from the batch call in score_image_batch_async

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@romanlutz romanlutz changed the title Reject explicit empty objectives in batch scoring FIX Reject explicit empty objectives in batch scoring Apr 24, 2026
@romanlutz romanlutz merged commit 8c95124 into microsoft:main Apr 24, 2026
45 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.

3 participants