weaviate/collections/classes/filters.py: an empty tuple passes equal() and five other filter builders, so the empty-list error only appears when the query runs
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 84/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- python
- Lĩnh vực
- backend-api-design, testing
Hướng nghiên cứu
Đọc sáu bước kiểm tra xác thực trong weaviate/collections/classes/filters.py tại các dòng 225, 235, 245, 255, 269 và 283, sau đó so sánh các giá trị được chấp nhận với _to_value_list trong weaviate/collections/filters.py. Bổ sung kiểm thử cho thấy cả sáu builder đều từ chối () trong khi equal("") vẫn hợp lệ; hoàn tất khi lỗi được phát sinh lúc tạo bộ lọc và các kiểm thử unit tập trung đều đạt.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
An empty tuple passes Filter.by_property(...).equal(()) and five sibling builders, while an empty list fails on the same call. The tuple's error appears only later, when a query converts the filter into its gRPC request.
Failure
_FilterByProperty.equal() builds the filter object a query later sends. It rejects an empty value only when isinstance(val, list) holds, so [] raises WeaviateInvalidInputError and () returns a filter. not_equal, less_than, less_or_equal, greater_than and greater_or_equal repeat the same check. FilterValuesList is typed as Sequence[...], so a type checker accepts the tuple.
One run on main at 200b57ea:
- A caller writes
f = Filter.by_property("tags").equal(()). Nothing raises, andfholds the empty tuple. - Later,
collection.query.fetch_objects(filters=f)builds its request. It calls_FilterToGRPC.convert(filters)atweaviate/collections/grpc/query.py:517, which turns a filter object into its protobuf message. _FilterToGRPC.__value_filterconverts any non-string sequence to a list with_to_value_listand finds it empty. It raisesWeaviateInvalidInputError: Filtering on empty lists is not supported by Weaviate.
The caller sees the right message, but the traceback points at fetch_objects instead of the line that built the filter. With equal([]) the same message points at equal(). Code that builds filters in one module and runs queries in another has to trace the tuple back by hand.
Reachability
Reachable. Any caller of the public Filter.by_property(...) API can pass an empty tuple, and nothing between that call and equal() converts it.
Severity
Low. The message is correct and no request reaches the server. Only the point where the error is raised is wrong.
Location
weaviate/collections/classes/filters.py:225, with the same check at :235, :245, :255, :269 and :283.
Excerpt
def equal(self, val: FilterValues) -> _Filters:
"""Filter on whether the property is equal to the given value."""
if isinstance(val, list) and len(val) == 0:
raise WeaviateInvalidInputError(
"Filtering on empty lists is not supported by Weaviate. "
"To filter by property length, use "
"Filter.by_property('prop', length=True).equal(0)"
)
return _FilterValue(target=self._target_path(), value=val, operator=_Operator.EQUAL)
Reproduction
No server is needed. The script calls _FilterToGRPC.convert, the same call fetch_objects makes at grpc/query.py:517.
from weaviate.classes.query import Filter
from weaviate.collections.filters import _FilterToGRPC
from weaviate.exceptions import WeaviateInvalidInputError
for name in ["equal", "not_equal", "less_than", "less_or_equal", "greater_than", "greater_or_equal"]:
for val in ([], ()):
try:
getattr(Filter.by_property("tags"), name)(val)
print(f"{name}({val!r}): builder accepted it")
except WeaviateInvalidInputError:
print(f"{name}({val!r}): builder raised WeaviateInvalidInputError")
f = Filter.by_property("tags").equal(())
try:
_FilterToGRPC.convert(f)
except WeaviateInvalidInputError as e:
print("convert raised WeaviateInvalidInputError:", e)
Run from the repository root with PYTHONPATH=. python repro.py on 200b57ea. It prints:
equal([]): builder raised WeaviateInvalidInputError
equal(()): builder accepted it
not_equal([]): builder raised WeaviateInvalidInputError
not_equal(()): builder accepted it
less_than([]): builder raised WeaviateInvalidInputError
less_than(()): builder accepted it
less_or_equal([]): builder raised WeaviateInvalidInputError
less_or_equal(()): builder accepted it
greater_than([]): builder raised WeaviateInvalidInputError
greater_than(()): builder accepted it
greater_or_equal([]): builder raised WeaviateInvalidInputError
greater_or_equal(()): builder accepted it
convert raised WeaviateInvalidInputError: Invalid input provided: Filtering on empty lists is not supported by Weaviate. To filter by property length, use Filter.by_property('prop', length=True).equal(0).
Suggested fix
In weaviate/collections/classes/filters.py, change the six checks to match any non-string sequence, the way _to_value_list in weaviate/collections/filters.py:23 does:
if isinstance(val, Sequence) and not isinstance(val, (str, bytes)) and len(val) == 0:
Keep the str and bytes exclusion, since equal("") is a valid filter on an empty string. A unit test asserting that each of the six methods raises WeaviateInvalidInputError for () confirms the fix. The six copies of the check could also become one helper.
Provenance
Pre-existing. The six checks come from 5cb7e1a9 (2026-02-12, "Fix empty list filter raising IndexError instead of WeaviateInvalidInputError"). #2169 (142d798a..200b57ea) changed only weaviate/collections/filters.py and its tests. Before #2169, the serializer also checked only for list, so the tuple reached the server as a filter with no value set. #2169 made the serializer reject it with the right message. Its description says it chose not to patch the builder methods. The closed #933 asked for this exception on empty lists.
Verification
Confirmed by the reproduction above on 200b57ea, which is on main since #2169 merged.
Where it surfaced
Review of #2169 (fix/filter-accepts-sequence-values, base main).
- Ngôn ngữ chính
- Python
- Star
- 230
- Fork
- 173
- Merge trung bình
- 4 ngày 16 giờ
- Pull request đã merge (30 ngày)
- 23
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của weaviate/weaviate-python-client
-
Batch: re-added rate-limited objects stay in results.objs.all_responses as errorsCó thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
weaviate/weaviate-python-client#2179 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
collections/batch: one object that fails client-side encoding fails every object sent with itCó thể đã có người làm @shadowmodder đã nhận hôm nay. Đang mởbug
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 72/100
weaviate/weaviate-python-client#2266 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
batch insert fails the whole batch with "ValueError: Unexpected type" when a value is a DecimalCó thể đã có người làm @steven-asearcy đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 35/100
weaviate/weaviate-python-client#2263 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
collections/batch/sync.py: after a fast hang-up reconnect the old stream's sender steals a request, hanging add_objectCó thể đã có người làm @shadowmodder đã nhận 2 ngày trước. Đang mởbug
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 45/100
weaviate/weaviate-python-client#2261 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
weaviate/weaviate-python-client#2259 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của weaviate/weaviate-python-client
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 67/100
-
breaking change
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 84/100
it-at-m/lhm_actions#441 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
TigreGotico/euskaphone#68 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[BUG] arc_agi_2: a correct grid in the format the prompt asks for scores 0 (exact_match gold is a one-line list)Có thể đã có người làm @BahaaMattar đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
huggingface/lighteval#1510 ·
Maintainer thường phản hồi trong vòng 1 ngày