Skip to content

fix(filters): serialize reference counts for GraphQL aggregation - #2233

Open
6londe wants to merge 1 commit into
weaviate:mainfrom
6londe:fix/graphql-reference-count-filter
Open

6londe wants to merge 1 commit into
weaviate:mainfrom
6londe:fix/graphql-reference-count-filter

Conversation

@6londe

@6londe 6londe commented Nov 2, 2026

Copy link
Copy Markdown

Reference-count filters raise AssertionError when collection aggregation uses the GraphQL fallback on Weaviate < 1.29:

collection.aggregate.over_all(
    filters=Filter.by_ref_count("ref").greater_than(0)
)

_FilterToREST.__to_path() does not handle _CountRef and falls through to the multi-target-reference assertion. Serialize its reference property as the GraphQL path, which is how the existing integer operand expresses a reference-count comparison. Add regression tests for both standalone and compound filters.

Validation on current main d1e185e:

  • Before: both new regression cases fail. Against a real isolated Weaviate 1.28.16 instance with two objects and one reference, raw GraphQL returns count 1, while both public sync and async aggregate calls raise AssertionError.
  • After: both public SDK calls return count 1, matching raw GraphQL.
  • pytest test/collection/test_filter.py test/collection/test_aggregates.py -q: 36 passed.
  • pytest test -q: 566 passed, 1 skipped (Python 3.12).
  • pre-commit run --files weaviate/collections/filters.py test/collection/test_filter.py and normal commit hooks: all passed, including stub generation, Ruff, flake8/docstrings and project Pyright.

The full integration/server-version matrix was not run. The gRPC serializer is unchanged.

AI disclosure: Codex investigated, generated, reviewed and tested this change; no independent human review is claimed.

@orca-security-eu orca-security-eu Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Orca Security Scan Summary

Status Check Issues by priority
Passed Passed Infrastructure as Code high 0   medium 0   low 0   info 0 View in Orca
Passed Passed SAST high 0   medium 0   low 0   info 0 View in Orca
Passed Passed Secrets high 0   medium 0   low 0   info 0 View in Orca
Passed Passed Vulnerabilities high 0   medium 0   low 0   info 0 View in Orca

@weaviate-git-bot

Copy link
Copy Markdown

To avoid any confusion in the future about your contribution to Weaviate, we work with a Contributor License Agreement. If you agree, you can simply add a comment to this PR that you agree with the CLA so that we can merge.

beep boop - the Weaviate bot 👋🤖

PS:
Are you already a member of the Weaviate Forum?

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants