Conversation
JsonSchemaValidator.run() read messages[-1] unconditionally, so an empty list leaked an IndexError. Raise a ValueError that names the problem instead, and document it under :raises:. Same approach as deepset-ai#12766, which was approved but closed without merging. Fixes deepset-ai#12765.
ShousenZHANG
requested review from
anakin87
and
a balanced review from Copilot
and removed request for
a team
October 2, 2026 11:09
Contributor
|
@ShousenZHANG 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 |
||||||||||||||||||||||||
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.
Related Issues
Proposed Changes:
JsonSchemaValidator.run()readsmessages[-1]before checking anything, so an emptymessageslist raisedIndexError: list index out of rangefrom inside the component (json_schema.py:135).It now raises
ValueError("The provided list of messages is empty.")first.ValueErroris whatrun()already raises for its other invalid inputs (a last message with no text, no schema at all), and the docstring's:raises ValueError:now lists the empty case too. Non-empty inputs take exactly the same path as before.How did you test it?
test_run_raises_clear_error_for_empty_messages. Before the fix it fails withIndexError: list index out of rangeatjson_schema.py:135; after it, it passes.test/components/validators/-> 21 passed. Full unit suite -> 6629 passed; the only failure is thespam.csvcase oftest_from_file_path_guess_mime_type, which fails identically on a cleanmaincheckout on Windows (local mime registry) and is untouched here.hatch run test:types-> no issues in 551 files.hatch run fmt-check-> clean.reno lint-> clean.Notes for the reviewer
Release note added under
fixes, since the exception type a caller sees for an empty list changes fromIndexErrortoValueError.This PR was written with AI assistance.