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] Search pagination with invalid offset value raised no exception #19250

Closed NicoYuan1986 closed 2 years ago

NicoYuan1986 commented 2 years ago

Is there an existing issue for this?

Environment

- Milvus version:master-20220916-11b352c
- Deployment mode(standalone or cluster):standalone
- SDK version(e.g. pymilvus v2.0.0rc2):2.2.0.dev30
- OS(Ubuntu or CentOS): 
- CPU/Memory: 
- GPU: 
- Others:

Current Behavior

Search pagination with invalid offset value raised no exception.

Expected Behavior

Return an error code. Such as ,MilvusException: (code=1, message=Invalid offset value, should be in range [...])

Steps To Reproduce

Run:

    @pytest.mark.tags(CaseLabel.L1)
    @pytest.mark.parametrize("offset", [-1, 16385])
    def test_search_with_invalid_offset_value(self, offset, auto_id, dim, _async):
        # 1. initialize
        collection_w = self.init_collection_general(prefix, True, auto_id=auto_id, 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

yanliang567 commented 2 years ago

/assign @XuanYang-cn /unassign

XuanYang-cn commented 2 years ago

/unassign /assign @NicoYuan1986 Please help verify

NicoYuan1986 commented 2 years ago

/unassign /assign @NicoYuan1986 Please help verify

Thank you for your help! The issue has been well solved now.