Skip to content

fix(probes): return no attempts when the prompt set is empty - #2027

Open
feiiiiii5 wants to merge 1 commit into
NVIDIA:mainfrom
feiiiiii5:fix/empty-prompts-indexerror-2026
Open

fix(probes): return no attempts when the prompt set is empty#2027
feiiiiii5 wants to merge 1 commit into
NVIDIA:mainfrom
feiiiiii5:fix/empty-prompts-indexerror-2026

Conversation

@feiiiiii5

Copy link
Copy Markdown
Contributor

Root Cause

Probe.probe() indexes prompts[0] without first checking that the prompt set is non-empty (garak/probes/base.py). A probe whose prompt set is empty — for example one emptied by the langprovider translation path (reproduced in tests/probes/test_probes.py::test_probe_prompt_translation[probes.sysprompt_extraction.SystemPromptExtraction] in #2022) — raises IndexError: list index out of range instead of producing no attempts. The progress bar two lines earlier already tolerates len(prompts) == 0; only the subscript does not.

Fix

Return [] (with a warning naming the probe) when the copied prompt set is empty, before the progress bar and the prompts[0] check. This mirrors the empty-set guard already present in IntentProbe.probe().

Test

  • New regression test test_probe_with_empty_prompts_returns_no_attempts: a Probe with prompts = [] returns [] instead of raising.
  • Verified locally: pytest tests/probes/test_probes.py::test_mint_attempt tests/probes/test_probes.py::test_probe_with_empty_prompts_returns_no_attempts → 5 passed.

Diff scope

2 files, +24/-1: garak/probes/base.py, tests/probes/test_probes.py.

AI Disclosure

AI-assisted implementation and regression test; human review of the empty-set semantics (no behavior change for non-empty probes; consistent with IntentProbe) and final diff before submission.

Closes #2026

probe() indexed prompts[0] before checking the list was non-empty, so a
probe whose prompt set was empty (e.g. emptied by translation) raised
IndexError instead of producing no attempts. This mirrors the empty-set
guard already present in IntentProbe.probe.

Closes NVIDIA#2026

Signed-off-by: fei <204683769+feiiiiii5@users.noreply.github.com>
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.

Probe.probe() raises IndexError when the prompt set is empty (translation can produce an empty set)

1 participant