fix(utils): raise clear ValueError for multi-hyphen page range strings - #11450
Closed
devteamaegis wants to merge 9 commits into
Closed
fix(utils): raise clear ValueError for multi-hyphen page range strings#11450devteamaegis wants to merge 9 commits into
devteamaegis wants to merge 9 commits into
Conversation
added 2 commits
May 31, 2026 18:59
expand_page_range() called page.split("-") without maxsplit, then
unpacked into exactly two variables. A range string like "5-10-15"
produced "too many values to unpack" instead of a useful error message.
Add maxsplit=1 and validate that both parts are digit strings before
expanding the range, raising a descriptive ValueError for malformed input.
Fixes deepset-ai#11449
|
@devteamaegis is attempting to deploy a commit to the deepset Team on Vercel. A member of the Team first needs to authorize it. |
|
|
Contributor
Coverage reportClick to see where and how coverage changed
This report was generated by python-coverage-comment-action |
||||||||||||||||||||||||
Contributor
|
@devteamaegis thanks for this contribution, you need to sign the CLA in order for the PR to be merged. |
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
Contributor
|
opened new PR due to user's inactivity #11475 |
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's broken
expand_page_range()inhaystack/utils/misc.pycrashes withValueError: too many values to unpack (expected 2)when any element of the input list contains more than one hyphen, e.g."5-10-15". This is a confusing internal error — the function should detect malformed input and raise a descriptiveValueErrorinstead. The function is a public utility used by the PDF-to-image converter and LLM metadata extractor components.Why it happens
Line 58 calls
page.split("-")without amaxsplitargument and immediately unpacks into exactly two variables. When the string has more than one hyphen,split()returns more than 2 elements, causing the internal unpack error rather than a clean validation failure.Fix
Added
maxsplit=1to thesplitcall and added a validation check that both resulting parts are digit strings. Malformed ranges now raiseValueError: Invalid page range: <value> - range must be a string in the format 'start-end', consistent with the error message used elsewhere in the function.Test
Added
TestExpandPageRange.test_malformed_range_with_multiple_hyphens_raises_clear_valueerrorintest/utils/test_misc.py. It passes["1-3", "5-10-15"]and asserts that aValueErrormatching"Invalid page range"is raised.Fixes #11449