fix(cleaners): return empty or blank text unchanged from clean_ordered_bullets
SA
9h ago+5+5+0123456789-0-0-0123456789
Summary
clean_ordered_bullets takes text.split()[0] without checking that the text has a word, so an empty or whitespace-only string raises IndexError: list index out of range:
>>> clean_ordered_bullets("")
IndexError: list index out of range
>>> clean_ordered_bullets(" ")
IndexError: list index out of range
Elements and page fragments can legitimately be blank, and every other input without a leading ordered bullet is returned unchanged. The fix returns blank text unchanged in the same way.
Validation
- Added
""," "and"\n"cases totest_clean_ordered_bullets; all three fail without the fix. pytest test_unstructured/cleaners/test_core.py: 167 passed.ruff checkandruff format --checkclean on the two touched files.
Release note
clean_ordered_bullets no longer raises IndexError on empty or whitespace-only text.
AI-assisted change. I reviewed the diff and ran the tests locally. I can't apply labels; this is a bug fix.