Skip to content

fix(python): validate numpy vector queries safely#502

Open
HosniBelfeki wants to merge 1 commit into
alibaba:mainfrom
HosniBelfeki:fix-python-query-numpy-validation
Open

fix(python): validate numpy vector queries safely#502
HosniBelfeki wants to merge 1 commit into
alibaba:mainfrom
HosniBelfeki:fix-python-query-numpy-validation

Conversation

@HosniBelfeki

Copy link
Copy Markdown

Summary

This is a small Python SDK validation hardening change.

When Query._validate() receives both id and a numpy vector, the previous truthiness check (self.id and self.vector) can trigger numpy's ambiguous truth-value error before Zvec raises its intended validation error.

This switches the check to the existing has_id() / has_vector() helpers and adds a regression test.

Tests

  • python -m ruff check python\zvec\model\param\query.py python\tests\test_params.py
  • $env:PYTHONPATH='python'; python -m pytest -o addopts= python/tests/test_params.py::TestQuery python/tests/test_fts_query.py::TestFtsQueryValidation -q

@HosniBelfeki HosniBelfeki requested a review from Cuiyus as a code owner June 17, 2026 07:41
@CLAassistant

CLAassistant commented Jun 17, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

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.

3 participants