Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion pymilvus/client/check.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ def is_correct_date_str(param: str) -> bool:
def is_legal_dimension(dim: Any) -> bool:
try:
_ = int(dim)
except ValueError:
except (TypeError, ValueError):
# int() raises TypeError, not ValueError, for a non-numeric type such as None
return False

return True
Expand Down
8 changes: 8 additions & 0 deletions tests/unit/test_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
is_legal_ids,
is_legal_port,
)
from pymilvus.exceptions import ParamError
from pymilvus.client.utils import (
hybridts_to_unixtime,
mkts_from_datetime,
Expand Down Expand Up @@ -138,6 +139,13 @@ def test_check_param_invalid(self):
a = {[i * j for i in range(20) for j in range(20)]}
check_pass_param(search_data=a)

@pytest.mark.parametrize("invalid_dimension", [None, [], {}, object()])
def test_check_pass_param_invalid_dimension(self, invalid_dimension):
# int() raises TypeError rather than ValueError for these, which used to escape
# is_legal_dimension instead of being reported as an illegal parameter
with pytest.raises(ParamError):
check_pass_param(dimension=invalid_dimension)


class TestGenTS:
def test_mkts1(self):
Expand Down