Skip to content

FIX: Return no message pieces for empty value filters in get_message_pieces - #4787

Open
simple-minded (hakarrr) wants to merge 3 commits into
microsoft:mainfrom
hakarrr:hakarrr-patch-b1
Open

simple-minded (hakarrr) wants to merge 3 commits into
microsoft:mainfrom
hakarrr:hakarrr-patch-b1

Conversation

@hakarrr

Copy link
Copy Markdown

Fixes #4773

get_message_pieces returned every piece when original_values, converted_values or converted_value_sha256 was an empty list, while prompt_ids=[] already returned []. An empty list now matches nothing for all four list filters. None still means no filter.

  • Extend the early return in _execute_get_message_pieces to cover the three value filters.
  • Add a parametrized test next to the existing prompt_ids=[] test, covering [] and None for each filter.

Co-authored-by: GeneralTony007 <144252170+GeneralTony007@users.noreply.github.com>
Co-authored-by: GeneralTony007 <144252170+GeneralTony007@users.noreply.github.com>
Co-authored-by: GeneralTony007 <144252170+GeneralTony007@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings December 1, 2026 19:43

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 making empty list filters return no message pieces.

No open issues 🎉

What changed in this PR

Fixes #4773 by making empty list filters consistently return no message pieces, preventing dynamically built empty filters from retrieving all stored pieces.

Changes:

  • Extend the existing prompt_ids=[] early return to all three value filters.
  • Add parametrized tests confirming that empty lists match nothing while None leaves results unfiltered.
File Description
tests/​unit/​memory/​memory_interface/​test_interface_prompts.py Test empty-list and None behavior for each value filter.
pyrit/​memory/​memory_interface.py Return an empty result when any of the four list filters is empty.

Review effort: Balanced

@hakarrr

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

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: get_message_pieces returns everything for empty original_values, converted_values and converted_value_sha256 lists

2 participants