Skip to content

fix(qdrant): respect falsy run() overrides in retrievers - #4007

Open
joshinitin2016883-sketch wants to merge 1 commit into
deepset-ai:mainfrom
joshinitin2016883-sketch:fix/qdrant-falsy-run-overrides
Open

joshinitin2016883-sketch wants to merge 1 commit into
deepset-ai:mainfrom
joshinitin2016883-sketch:fix/qdrant-falsy-run-overrides

Conversation

@joshinitin2016883-sketch

Copy link
Copy Markdown
Contributor

Related Issues

Proposed Changes:

QdrantEmbeddingRetriever, QdrantSparseEmbeddingRetriever and QdrantHybridRetriever resolve their run() / run_async() overrides with or:

scale_score=scale_score or self._scale_score,
return_embedding=return_embedding or self._return_embedding,
score_threshold=score_threshold or self._score_threshold,

or falls back on any falsy value, so valid overrides are replaced by the init values:

retriever = QdrantEmbeddingRetriever(document_store, scale_score=True, return_embedding=True, score_threshold=0.5)
retriever.run(query_embedding=[0.1, 0.2], scale_score=False, return_embedding=False, score_threshold=0.0)
# the store receives scale_score=True, return_embedding=True, score_threshold=0.5

This change falls back to the init value only when the argument is None, which is how QdrantHybridRetriever already resolves rrf_k and rrf_weights in the same file.

I left top_k, group_by and group_size unchanged: none of them has a meaningful falsy value.

How did you test it?

  • Regression tests: test_run_falsy_runtime_values_override_init and test_run_async_falsy_runtime_values_override_init in each of the three retriever test files. All 6 fail before the change (assert True is False) and pass after.
  • Unit tests: 142 passed. Integration tests (in-memory Qdrant): 157 passed, 1 skipped.
  • ruff check, ruff format --check and mypy (using the integration's config) are clean.

Hatch is blocked by Windows Application Control on my machine, so these ran from a venv with the integration installed in editable mode rather than through hatch run.

Notes for the reviewer

Checklist

  • I have read the contributors guidelines and the code of conduct
  • I have updated the related issue with new insights and changes
  • I added unit tests and updated the docstrings
  • I've used one of the conventional commit types for my PR title

🤖 Generated with Claude Code

The Qdrant retrievers resolved scale_score, return_embedding and
score_threshold with `or`, so run(scale_score=False),
run(return_embedding=False) and run(score_threshold=0.0) were silently
replaced by the init values. Fall back to the init value only when the
argument is None, as QdrantHybridRetriever already does for rrf_k.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@joshinitin2016883-sketch
joshinitin2016883-sketch requested a review from a team as a code owner September 25, 2026 17:00
@joshinitin2016883-sketch
joshinitin2016883-sketch requested review from bogdankostic and removed request for a team September 25, 2026 17:00
@github-actions

Copy link
Copy Markdown
Contributor

Coverage report (qdrant)

This PR does not seem to contain any modification to coverable code.

@bogdankostic bogdankostic self-assigned this Sep 28, 2026

@bogdankostic bogdankostic left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @joshinitin2016883-sketch! Looks already good in general, just left one suggestion on making the code more readable.

Comment on lines +191 to +193
scale_score=self._scale_score if scale_score is None else scale_score,
return_embedding=self._return_embedding if return_embedding is None else return_embedding,
score_threshold=self._score_threshold if score_threshold is None else score_threshold,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's put the runtime value first, not only here but thoughout the file.

Suggested change
scale_score=self._scale_score if scale_score is None else scale_score,
return_embedding=self._return_embedding if return_embedding is None else return_embedding,
score_threshold=self._score_threshold if score_threshold is None else score_threshold,
scale_score=scale_score if scale_score is not None else self._scale_score,
return_embedding=return_embedding if return_embedding is not None else self._return_embedding,
score_threshold=score_threshold if score_threshold is not None else self._score_threshold,

This branch has not been deployed

No deployments
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