Commit edcadec
fix: raise FilterError on unknown metadata filter operators
Filtering with an unsupported operator (e.g. a typo like "gt" instead of
">", or "XOR" as a logical operator) raised a bare KeyError with no
context. Since filters.py is the shared filter engine used by
InMemoryDocumentStore and every external document store, this affected
all stores.
Both _comparison_condition and _logic_condition now validate the
operator and raise a FilterError that lists the valid operators,
consistent with how other malformed-filter cases are already handled.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>1 parent 0500a97 commit edcadec
3 files changed
Lines changed: 20 additions & 0 deletions
File tree
- haystack/utils
- releasenotes/notes
- test/utils
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
173 | 173 | | |
174 | 174 | | |
175 | 175 | | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
176 | 179 | | |
177 | 180 | | |
178 | 181 | | |
| |||
214 | 217 | | |
215 | 218 | | |
216 | 219 | | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
217 | 223 | | |
218 | 224 | | |
Lines changed: 8 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
566 | 566 | | |
567 | 567 | | |
568 | 568 | | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
569 | 575 | | |
570 | 576 | | |
571 | 577 | | |
| |||
0 commit comments