Skip to content

fix: treat dict payloads as scalar values in values_count filter#1192

Open
rahulkini31 wants to merge 1 commit into
qdrant:masterfrom
rahulkini31:fix/values-count-dict-payload
Open

fix: treat dict payloads as scalar values in values_count filter#1192
rahulkini31 wants to merge 1 commit into
qdrant:masterfrom
rahulkini31:fix/values-count-dict-payload

Conversation

@rahulkini31
Copy link
Copy Markdown

Summary

  • get_value_counts in payload_filters.py used hasattr(value, "__len__") to detect array-like values, but dict also has __len__, causing JSON object payloads to be counted by their number of keys instead of as 1 scalar value.
  • Adds dict to the isinstance exclusion alongside str so dict payloads correctly count as 1.
  • Adds tests covering: dict with multiple keys, empty dict, nested dict, all four comparison operators (gt, lt, gte, lte), and a regression guard for list counting.

Test plan

  • pytest qdrant_client/local/tests/test_payload_filters.py -x — 3 tests pass (including new test)
  • pytest qdrant_client/local/tests/ -x — 56 tests pass
  • pytest tests/test_in_memory.py tests/test_local_persistence.py tests/test_common.py tests/conversions/ tests/test_fastembed.py -x — 115 tests pass, 0 failures
  • mypy qdrant_client/local/payload_filters.py — no issues
  • ruff format --check — already formatted

🤖 Generated with Claude Code

`get_value_counts` used `hasattr(value, "__len__")` to detect arrays,
but `dict` also has `__len__`, causing JSON object payloads to be
counted by their number of keys instead of as a single scalar value.

Add `dict` to the `isinstance` exclusion alongside `str` so that
dict payloads correctly count as 1.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@netlify
Copy link
Copy Markdown

netlify Bot commented Apr 18, 2026

Deploy Preview for poetic-froyo-8baba7 ready!

Name Link
🔨 Latest commit 7894bcc
🔍 Latest deploy log https://app.netlify.com/projects/poetic-froyo-8baba7/deploys/69e39b0c13ee780008a4f0c5
😎 Deploy Preview https://deploy-preview-1192--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
Copy link
Copy Markdown

coderabbitai Bot commented Apr 18, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 5ae0c21d-aa16-4c76-8a98-1f5d0cd67b34

📥 Commits

Reviewing files that changed from the base of the PR and between cd5eb25 and 7894bcc.

📒 Files selected for processing (2)
  • qdrant_client/local/payload_filters.py
  • qdrant_client/local/tests/test_payload_filters.py

📝 Walkthrough

Walkthrough

This PR modifies the get_value_counts function in payload_filters.py to exclude dictionary values from length-based counting, treating them as scalar JSON values that count as 1 instead of their key count. A corresponding test case verifies that dictionaries are counted as single values while lists continue to be counted by their element count, and that comparison operators behave consistently for dictionary payloads.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • fix: fix local mode values count #1191 — Modifies the same get_value_counts logic to change which payload types are treated as countable collections, restricting len-based counting to lists instead of excluding dicts and strings.
🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: treating dict payloads as scalar values in the values_count filter, which directly matches the primary code change in payload_filters.py.
Description check ✅ Passed The description is directly related to the changeset, providing clear context about the bug (dict having len causing incorrect counting), the fix applied, test coverage added, and comprehensive test results.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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 and usage tips.

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