Skip to content

Commit c1dc050

Browse files
committed
PYCBC-1681: Raise InvalidArgumentException when base64 vector string is empty
Motivation ========== Base64 vector strings cannot be empty. The RFC requires us to throw an InvalidArgumentException. Change ====== If an empty base64 vector string is given, fail with an InvalidArgumentException. Results ======= Relevant FIT test passes (VectorSearchBase64Test.base64QueryWithEmptyBase64StringThrowInvalidArgument) Change-Id: I479bb87b4b326a0c59631816dcc043d25e409b18 Reviewed-on: https://review.couchbase.org/c/couchbase-python-client/+/225921 Tested-by: Build Bot <build@couchbase.com> Reviewed-by: Jared Casey <jared.casey@couchbase.com>
1 parent ddad424 commit c1dc050

2 files changed

Lines changed: 4 additions & 1 deletion

File tree

couchbase/logic/vector_search.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,9 @@ def _validate_and_set_vector(self,
127127
elif not isinstance(vector, str):
128128
raise InvalidArgumentException('Provided vector must be either a List[float] or base64 encoded str.')
129129

130+
if len(vector) == 0:
131+
raise InvalidArgumentException('Provided base64 encoded vector cannot be empty.')
132+
130133
self._vector_base64 = vector
131134

132135
@classmethod

deps/couchbase-cxx-client

0 commit comments

Comments
 (0)