Skip to content

fix: AnswerJoiner no longer crashes when sorting answers with a None score#11701

Open
hoangsonww wants to merge 1 commit into
deepset-ai:mainfrom
hoangsonww:fix/answerjoiner-sort-by-score-none
Open

fix: AnswerJoiner no longer crashes when sorting answers with a None score#11701
hoangsonww wants to merge 1 commit into
deepset-ai:mainfrom
hoangsonww:fix/answerjoiner-sort-by-score-none

Conversation

@hoangsonww

Copy link
Copy Markdown

Related Issues

None. Bug found during code review; no existing tracking issue.

Proposed Changes:

AnswerJoiner.run(sort_by_score=True) raised TypeError: '<' not supported between instances of 'float' and 'NoneType' whenever any answer had score=None. The docstring states that an answer without a score is treated as if its score were negative infinity, but the sort key guarded on hasattr(answer, "score"), which is True for an ExtractedAnswer whose score is None. The key now uses getattr(answer, "score", None) and falls back to -inf when the value is missing or None, so such answers sort last as documented.

How did you test it?

Added three regression tests to test/components/joiners/test_answer_joiner.py: a None score, an answer type with no score attribute (GeneratedAnswer), and ordinary score ordering. Verified that the new None-score test fails against the pre-fix code with the exact TypeError, then passes with the fix. hatch run test:unit test/components/joiners/ passes (78), hatch run test:types (mypy) is clean, and hatch run fmt reports 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

  • I have read the contributors guidelines and the code of conduct.
  • I have updated the related issue with new insights and changes.
  • I have added unit tests and updated the docstrings.
  • I've used one of the conventional commit types for my PR title: fix:, feat:, build:, chore:, ci:, docs:, style:, refactor:, perf:, test: and added ! in case the PR includes breaking changes.
  • I have documented my code.
  • I have added a release note file, following the contributors guidelines.
  • I have run pre-commit hooks and fixed any issue.

@hoangsonww hoangsonww requested a review from a team as a code owner June 21, 2026 23:24
@hoangsonww hoangsonww requested review from bogdankostic and removed request for a team June 21, 2026 23:24
@vercel

vercel Bot commented Jun 21, 2026

Copy link
Copy Markdown

@hoangsonww is attempting to deploy a commit to the deepset Team on Vercel.

A member of the Team first needs to authorize it.

@CLAassistant

CLAassistant commented Jun 21, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants