fix: ignore non-list QueryExpander replies#11630
Merged
anakin87 merged 2 commits intoJun 15, 2026
Merged
Conversation
|
@oyinkanchekwas is attempting to deploy a commit to the deepset Team on Vercel. A member of the Team first needs to authorize it. |
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Improves QueryExpander robustness when parsing LLM JSON by rejecting malformed "queries" fields that aren’t lists, preventing accidental iteration over strings (character-by-character) and similar invalid structures.
Changes:
- Added a type check in
_parse_expanded_queriesto return[](and warn) when"queries"is not a list. - Added parametrized test coverage for several non-list
"queries"values. - Added release note documenting the behavior change.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| test/components/query/test_query_expander.py | Adds parametrized tests ensuring non-list "queries" values are rejected and logged. |
| haystack/components/query/query_expander.py | Adds a guard + warning to prevent iterating invalid "queries" types (e.g., strings). |
| releasenotes/notes/query-expander-reject-non-list-queries-6f3b1c2d8e9a4b70.yaml | Documents the fix in release notes. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+268
to
+273
| if not isinstance(parsed["queries"], list): | ||
| logger.warning( | ||
| "Expected 'queries' to be a list but got {type}. Returning no expanded queries.", | ||
| type=type(parsed["queries"]).__name__, | ||
| ) | ||
| return [] |
Contributor
Coverage reportClick to see where and how coverage changed
This report was generated by python-coverage-comment-action |
||||||||||||||||||||||||
anakin87
reviewed
Jun 15, 2026
…1c2d8e9a4b70.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
QueryExpandernow checks thatqueriesis a list before iterating over it.Before this, a response like
{"queries": "search term"}was treated as an iterable, so it produced single-character queries.Testing
hatch run test:unit test/components/query/test_query_expander.py -qhatch run fmt-check haystack/components/query/query_expander.py test/components/query/test_query_expander.pyhatch run test:types haystack/components/query/query_expander.py test/components/query/test_query_expander.py