milvus-io / milvus

A cloud-native vector database, storage for next generation AI applications
https://milvus.io
Apache License 2.0
30.36k stars 2.91k forks source link

[Bug]: [Pagination] Error message is not exact when offset < 0 #19346

Closed NicoYuan1986 closed 2 years ago

NicoYuan1986 commented 2 years ago

Is there an existing issue for this?

Environment

- Milvus version:42d371f
- Deployment mode(standalone or cluster):standalone
- SDK version(e.g. pymilvus v2.0.0rc2):2.2.0.dev32
- OS(Ubuntu or CentOS): 
- CPU/Memory: 
- GPU: 
- Others:

Current Behavior

When offset < 0 and offset + limit <= 0 ,the error message only mentioned limit even if the limit is correct. For example, when offset = -10 and limit = 10, we'll get <MilvusException: (code=1, message=limit should be in range [1, 16385], but got 0)>.

Expected Behavior

Error message should be more exact and user friendly.

Steps To Reproduce

Run this case to get the same result.

    @pytest.mark.tags(CaseLabel.L1)
    @pytest.mark.parametrize("offset", [-10])
    def test_search_pagination_with_invalid_offset_value(self, offset, dim, _async):
        """
        target: test search pagination with invalid offset value
        method: create connection, collection, insert and search with invalid offset value
        expected: search successfully
        """
        # 1. initialize
        collection_w = self.init_collection_general(prefix, True, dim=dim)[0]
        # 2. search
        search_param = {"metric_type": "L2", "params": {"nprobe": 10}, "offset": offset}
        vectors = [[random.random() for _ in range(dim)] for _ in range(default_nq)]
        collection_w.search(vectors[:default_nq], default_search_field,
                            search_param, default_limit,
                            default_search_exp, _async=_async,
                            check_task=CheckTasks.check_search_results,
                            check_items={"nq": default_nq,
                                         "limit": default_limit,
                                         "_async": _async})

Milvus Log

No response

Anything else?

No response

XuanYang-cn commented 2 years ago

19388

NicoYuan1986 commented 2 years ago

Fixed.