diff --git a/internal/proxy/task.go b/internal/proxy/task.go index 73c8c6a6a8..3bf0cf64eb 100644 --- a/internal/proxy/task.go +++ b/internal/proxy/task.go @@ -471,9 +471,9 @@ func (t *dropCollectionTask) OnEnqueue() error { } func (t *dropCollectionTask) PreExecute(ctx context.Context) error { - if err := validateCollectionName(t.CollectionName); err != nil { - return err - } + // No need to check collection name + // Validation shall be preformed in `CreateCollection` + // also permit drop collection one with bad collection name return nil } diff --git a/internal/proxy/task_alias.go b/internal/proxy/task_alias.go index 7ded860764..6d78d1fdeb 100644 --- a/internal/proxy/task_alias.go +++ b/internal/proxy/task_alias.go @@ -179,10 +179,9 @@ func (t *DropAliasTask) OnEnqueue() error { } func (t *DropAliasTask) PreExecute(ctx context.Context) error { - collAlias := t.Alias - if err := ValidateCollectionAlias(collAlias); err != nil { - return err - } + // No need to check collection name + // Validation shall be preformed in `CreateCollection` + // also permit drop collection one with bad collection name return nil } diff --git a/internal/proxy/task_test.go b/internal/proxy/task_test.go index 58b135391e..a424e57651 100644 --- a/internal/proxy/task_test.go +++ b/internal/proxy/task_test.go @@ -2554,13 +2554,10 @@ func Test_createIndexTask_PreExecute(t *testing.T) { func Test_dropCollectionTask_PreExecute(t *testing.T) { dct := &dropCollectionTask{DropCollectionRequest: &milvuspb.DropCollectionRequest{ Base: &commonpb.MsgBase{}, - CollectionName: "0xffff", // invalid + CollectionName: "valid", // invalid }} ctx := context.Background() err := dct.PreExecute(ctx) - assert.Error(t, err) - dct.DropCollectionRequest.CollectionName = "valid" - err = dct.PreExecute(ctx) assert.NoError(t, err) } diff --git a/internal/proxy/util.go b/internal/proxy/util.go index f7eb76d6df..3f4fae8fd6 100644 --- a/internal/proxy/util.go +++ b/internal/proxy/util.go @@ -152,8 +152,6 @@ func validateNQLimit(limit int64) error { } func validateCollectionNameOrAlias(entity, entityType string) error { - entity = strings.TrimSpace(entity) - if entity == "" { return merr.WrapErrParameterInvalidMsg("collection %s should not be empty", entityType) } diff --git a/internal/proxy/util_test.go b/internal/proxy/util_test.go index 30f15251ec..da61b6d7e5 100644 --- a/internal/proxy/util_test.go +++ b/internal/proxy/util_test.go @@ -69,6 +69,7 @@ func TestValidateCollectionName(t *testing.T) { "", string(longName), "中文", + "abc ", } for _, name := range invalidNames { diff --git a/tests/python_client/milvus_client/test_milvus_client_alias.py b/tests/python_client/milvus_client/test_milvus_client_alias.py index 7a5531daef..29fe594ca0 100644 --- a/tests/python_client/milvus_client/test_milvus_client_alias.py +++ b/tests/python_client/milvus_client/test_milvus_client_alias.py @@ -196,6 +196,7 @@ class TestMilvusClientAliasInvalid(TestMilvusClientV2Base): @pytest.mark.tags(CaseLabel.L1) @pytest.mark.parametrize("alias_name", ["12-s", "12 s", "(mn)", "中文", "%$#"]) + @pytest.mark.skip(reason="https://github.com/milvus-io/milvus/pull/43064 change drop alias restraint") def test_milvus_client_drop_alias_invalid_alias_name(self, alias_name): """ target: test create same alias to different collections @@ -210,6 +211,7 @@ class TestMilvusClientAliasInvalid(TestMilvusClientV2Base): check_task=CheckTasks.err_res, check_items=error) @pytest.mark.tags(CaseLabel.L1) + @pytest.mark.skip(reason="https://github.com/milvus-io/milvus/pull/43064 change drop alias restraint") def test_milvus_client_drop_alias_over_max_length(self): """ target: test create same alias to different collections diff --git a/tests/python_client/milvus_client/test_milvus_client_collection.py b/tests/python_client/milvus_client/test_milvus_client_collection.py index c937b429f0..1162ebdb5d 100644 --- a/tests/python_client/milvus_client/test_milvus_client_collection.py +++ b/tests/python_client/milvus_client/test_milvus_client_collection.py @@ -88,7 +88,7 @@ class TestMilvusClientCollectionInvalid(TestMilvusClientV2Base): client = self._client() # 1. create collection collection_name = " " - error = {ct.err_code: 0, ct.err_msg: "collection name should not be empty: invalid parameter"} + error = {ct.err_code: 1100, ct.err_msg: "Invalid collection name"} self.create_collection(client, collection_name, default_dim, check_task=CheckTasks.err_res, check_items=error) @@ -621,6 +621,7 @@ class TestMilvusClientDropCollectionInvalid(TestMilvusClientV2Base): @pytest.mark.tags(CaseLabel.L1) @pytest.mark.parametrize("name", ["12-s", "12 s", "(mn)", "中文", "%$#"]) + @pytest.mark.skip(reason="https://github.com/milvus-io/milvus/pull/43064 change drop alias restraint") def test_milvus_client_drop_collection_invalid_collection_name(self, name): """ target: test fast create collection normal case diff --git a/tests/python_client/testcases/test_utility.py b/tests/python_client/testcases/test_utility.py index b95f7fce40..ad3c71b941 100644 --- a/tests/python_client/testcases/test_utility.py +++ b/tests/python_client/testcases/test_utility.py @@ -197,7 +197,7 @@ class TestUtilityParams(TestcaseBase): """ self._connect() error = {ct.err_code: 999, ct.err_msg: f"Invalid collection name: {invalid_name}"} - if invalid_name in [None, "", " "]: + if invalid_name in [None, ""]: error = {ct.err_code: 999, ct.err_msg: "collection name should not be empty"} self.utility_wrap.index_building_progress(collection_name=invalid_name, check_task=CheckTasks.err_res, check_items=error)