fix: AnswerJoiner no longer crashes when sorting answers with a None score#11701
Open
hoangsonww wants to merge 1 commit into
Open
fix: AnswerJoiner no longer crashes when sorting answers with a None score#11701hoangsonww wants to merge 1 commit into
hoangsonww wants to merge 1 commit into
Conversation
|
@hoangsonww is attempting to deploy a commit to the deepset Team on Vercel. A member of the Team first needs to authorize it. |
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
None. Bug found during code review; no existing tracking issue.
Proposed Changes:
AnswerJoiner.run(sort_by_score=True)raisedTypeError: '<' not supported between instances of 'float' and 'NoneType'whenever any answer hadscore=None. The docstring states that an answer without a score is treated as if its score were negative infinity, but the sort key guarded onhasattr(answer, "score"), which isTruefor anExtractedAnswerwhosescoreisNone. The key now usesgetattr(answer, "score", None)and falls back to-infwhen the value is missing orNone, so such answers sort last as documented.How did you test it?
Added three regression tests to
test/components/joiners/test_answer_joiner.py: aNonescore, an answer type with noscoreattribute (GeneratedAnswer), and ordinary score ordering. Verified that the newNone-score test fails against the pre-fix code with the exactTypeError, then passes with the fix.hatch run test:unit test/components/joiners/passes (78),hatch run test:types(mypy) is clean, andhatch run fmtreports no changes.Notes for the reviewer
Minimal, isolated change to one component plus tests and a release note. The docstring already documented the negative-infinity behavior, so the fix brings the code in line with the documented contract rather than changing it.
Checklist
fix:,feat:,build:,chore:,ci:,docs:,style:,refactor:,perf:,test:and added!in case the PR includes breaking changes.