Commit 881ca5c
committed
fix: raise ValueError for reversed page ranges in expand_page_range
A reversed page range like '5-3' would either raise a confusing
'No valid page numbers or ranges found' error (when it was the only
entry) or silently drop the pages when mixed with valid ranges (e.g.
['1-3', '7-5', '8'] returned [1, 2, 3, 8] instead of raising).
Add an explicit check that start <= end and raise a clear ValueError
with a descriptive message identifying the problematic range.
Also adds three new tests covering:
- reversed range alone raises ValueError
- reversed range mixed with valid ranges raises ValueError (no silent drop)
- equal start and end (e.g. '3-3') is valid and returns [3]1 parent ed472f0 commit 881ca5c
3 files changed
Lines changed: 25 additions & 2 deletions
File tree
- haystack/utils
- releasenotes/notes
- test/utils
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
64 | | - | |
65 | | - | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
66 | 69 | | |
67 | 70 | | |
68 | 71 | | |
| |||
Lines changed: 7 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
195 | 195 | | |
196 | 196 | | |
197 | 197 | | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
0 commit comments