From d578d5b317ec6ef8de21518c2c7c0cbbe14dd832 Mon Sep 17 00:00:00 2001 From: yukun Date: Sat, 26 Jun 2021 14:30:04 +0800 Subject: [PATCH] Check if output_fields is list (#579) * Check if output_fields is list Signed-off-by: kun yu * output_fields shoulbe be list Signed-off-by: kun yu * Add output_fields check to search Signed-off-by: kun yu --- pymilvus/client/grpc_handler.py | 2 ++ pymilvus/client/prepare.py | 3 +++ 2 files changed, 5 insertions(+) diff --git a/pymilvus/client/grpc_handler.py b/pymilvus/client/grpc_handler.py index 6db79adc0..c1aa25bac 100644 --- a/pymilvus/client/grpc_handler.py +++ b/pymilvus/client/grpc_handler.py @@ -1006,6 +1006,8 @@ def get(self, collection_name, ids, output_fields=None, partition_names=None, ti @error_handler() def query(self, collection_name, expr, output_fields=None, partition_names=None, timeout=None): + if output_fields is not None and not isinstance(output_fields, (list, )): + raise ParamError("Invalid query format. 'output_fields' must be a list") request = Prepare.query_request(collection_name, expr, output_fields, partition_names) future = self._stub.Query.future(request, wait_for_ready=True, timeout=timeout) response = future.result() diff --git a/pymilvus/client/prepare.py b/pymilvus/client/prepare.py index 10b2277d3..a3126f560 100644 --- a/pymilvus/client/prepare.py +++ b/pymilvus/client/prepare.py @@ -456,6 +456,9 @@ def search_request(cls, collection_name, query_entities, partition_names=None, f if not isinstance(query_entities, (dict,)): raise ParamError("Invalid query format. 'query_entities' must be a dict") + if fields is not None and not isinstance(fields, (list, )): + raise ParamError("Invalid query format. 'fields' must be a list") + request = milvus_types.SearchRequest( collection_name=collection_name, partition_names=partition_names,