Skip to content

fix(local): reject score_threshold with an order_by query - #1532

Open
kabishou11 wants to merge 1 commit into
qdrant:devfrom
kabishou11:fix/local-orderby-score-threshold
Open

kabishou11 wants to merge 1 commit into
qdrant:devfrom
kabishou11:fix/local-orderby-score-threshold

Conversation

@kabishou11

Copy link
Copy Markdown

All Submissions:

  • Contributions should target the dev branch. Did you create your branch from dev?
  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same update/change?

Changes to Core Features:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your core changes, as applicable?
  • Have you successfully ran tests with your changes locally?

What and why

The server rejects a score_threshold combined with an order_by query, both at the top level and inside a prefetch (checked against Qdrant 1.19.1):

400 Bad request: Can't use score_threshold with an order_by query.

Local mode silently ignored the threshold and returned every ordered point with score 1.0, so code that works in :memory: fails against a real server:

client.query_points(
    "col", query=models.OrderByQuery(order_by="n"), score_threshold=0.5
)
# local: OK, ids=[1, 2, 3], scores=[1.0, 1.0, 1.0]
# server: 400 Can't use score_threshold with an order_by query.

This adds the same check next to the existing local validation (_validate_prefetch, query_points, query_points_groups) in QdrantLocal and AsyncQdrantLocal. SampleQuery with a threshold is accepted by the server, so it is left unchanged.

Tests

tests/congruence_tests/test_query.py::test_query_orderby_with_score_threshold_is_rejected checks the top-level and prefetch cases: local raises ValueError, REST raises UnexpectedResponse, gRPC raises RpcError. It fails on dev and passes with the change (Qdrant 1.19.1 server). The existing order-by congruence tests still pass, and pre-commit run on the changed files passes.

The server answers query_points with an OrderByQuery and a
score_threshold (top level or in a prefetch) with 400 "Can't use
score_threshold with an order_by query.". Local mode ignored the
threshold and returned every ordered point with score 1.0. Raise the
same error in query_points, query_points_groups and prefetch validation.
@kabishou11
kabishou11 requested a review from joein as a code owner October 5, 2026 00:42
@netlify

netlify Bot commented Oct 5, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for poetic-froyo-8baba7 ready!

Name Link
🔨 Latest commit 86c2576
🔍 Latest deploy log https://app.netlify.com/projects/poetic-froyo-8baba7/deploys/6ac2f2607193cc0008a6fe3d
😎 Deploy Preview https://deploy-preview-1532--poetic-froyo-8baba7.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@coderabbitai

coderabbitai Bot commented Oct 5, 2026

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 554733a7-ce05-47a1-82b5-02e78d304b20
📥 Commits

Reviewing files that changed from the base of the PR and between d64b76d and 86c2576.

📒 Files selected for processing (3)
  • qdrant_client/local/async_qdrant_local.py
  • qdrant_client/local/qdrant_local.py
  • tests/congruence_tests/test_query.py

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.


📝 Walkthrough

Walkthrough

The synchronous and asynchronous local clients now raise ValueError when a query or prefetch combines score_threshold with an OrderByQuery. Tests cover root queries and RRF prefetches with local, HTTP, and gRPC clients.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 86c25

The local clients now reject the incompatible query combination, and the supplied coverage identifies no issue requiring a fix before merge.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 8 functions across 3 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: rejecting score_threshold with an order_by query in local mode.
Description check ✅ Passed The description explains the local-mode behavior, the server behavior, the validation changes, and the tests. It is directly related to the changeset.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant