Repository navigation
Conversation
INCLUDE_VECTOR is Union[bool, str, List[str]], and the validator accepts bool, str and Sequence, so passing one named vector as a string is a valid call. _MetadataQuery.from_public handled only bool and list, so a str matched neither branch: MetadataRequest asked for no vector at all and the caller got none back, with no error. _QueryOptions meanwhile recorded include_vector=True, so the response parser was told to expect one. Normalises str to [str] at the top of from_public.
There was a problem hiding this comment.
Orca Security Scan Summary
| Status | Check | Issues by priority | |
|---|---|---|---|
| Infrastructure as Code | View in Orca | ||
| SAST | View in Orca | ||
| Secrets | View in Orca | ||
| Vulnerabilities | View in Orca |
|
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. |
|
I agree to the CLA |
dirkkul
left a comment
There was a problem hiding this comment.
Change LGTM, but tests need rework. Btw the same problem exists for tuples (which are also a sequence) in case you also want to fix that
| @@ -0,0 +1,32 @@ | |||
| """`include_vector` accepts a bare ``str`` but then requests no vector at all. | |||
There was a problem hiding this comment.
Instead of these unit test, could we just change an integration test? That is the best "proof" that this works front to back:
test_batch_add in integration/test_vectors.py:248 already inserts an object with a vector the test supplies itself, bringYourOwn =
[0.5, 0.25, 0.75]. At :270 it fetches that object with the list form. Add the plain-string form after :272:
obj = collection.query.fetch_object_by_id(uuid1, include_vector="bringYourOwn")
assert obj.vector == {"bringYourOwn": [0.5, 0.25, 0.75]}
A tuple passes the Sequence check in _parse_return_metadata and then, like a bare str before it, requested no vector at all. Convert it to a list next to the str case. Replace the unit tests with two fetches in integration test_batch_add, which already inserts its own bringYourOwn vector, as review asked. Signed-off-by: Christopher Krah <48338417+chrikrah@users.noreply.github.com>
chrikrah
left a comment
There was a problem hiding this comment.
@dirkkul done: the unit file is gone, and test_batch_add now fetches bringYourOwn once as a bare string and once as a one-element tuple. I took the tuple case as well, since a tuple passes the Sequence check and then asked the server for nothing, just as the string did.
# git archive of c360560 (this push, on f5f7bff), Python 3.12, weaviate.__file__ from the export
# server: weaviate 1.40.2 + contextionary en0.16.0-v1.2.0, the two ci/docker-compose.yml services
$ pytest -q integration/test_vectors.py -k test_batch_add
1 passed
# grpc.py from f5f7bff (string fix only): fails at test_vectors.py:278, the tuple fetch returns {}
# grpc.py from main e89eca5 (no fix): fails at test_vectors.py:275, the string fetch returns {}
$ pytest -q -n 4 integration/test_vectors.py
32 passed, 3 skipped
$ pytest -q -n 4 test
572 passed, 1 skipped
$ SKIP=no-commit-to-branch pre-commit run --all-files # ruff 0.14.7, pyright 1.1.400
all hooks passed
Could you take another look once it's up? Both of your points are in this push.
No open issue covers this.
INCLUDE_VECTORisUnion[bool, str, List[str]], and the validator acceptsbool,strandSequence, so one named vector passed as a string is a valid call._MetadataQuery.from_publicatgrpc.py:147handles onlyboolandlist, so astrmatches neither branch andMetadataRequestasks for nothing:The caller gets no vector and no error, while
_QueryOptionsrecordsTrue, so the response parser is told to expect one. The fix normalisesstrto[str]at the top offrom_public.Baseline on
eb5546ais591 passed, 1 skipped, so the delta is the three new cases. Revertinggrpc.pyand keeping them gives2 failed, 592 passed.The one existing test for this argument,
test_queries.py:100, assertsinclude_vector=42raises. Thestrpath was untested.I did not confirm this against a running Weaviate: no Docker here, so
integration/andjourney_tests/did not run. The proof is on the request-construction side, which needs no server, because a request that asks for no vector cannot return one.ruffis not installed in this venv, so I did not lint.@dirkkul you and @g-despot merge most of the client changes here, and
CODEOWNERScovers only.github/andci/. Worth astroverload on the type alias instead, or is normalising enough?