From 6a4a9debd239e1f7c1cb9013a0ae4dee5f4abf6a Mon Sep 17 00:00:00 2001 From: Lynn Date: Thu, 26 Mar 2026 19:06:51 +0800 Subject: [PATCH] Fix: allow create dataset with resume chunk_method (#13798) ### What problem does this PR solve? Allow create dataset with resume chunk_method. ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue) --- api/utils/validation_utils.py | 4 ++-- .../test_dataset_management/test_create_dataset.py | 4 ++-- .../test_dataset_management/test_update_dataset.py | 4 ++-- .../test_dataset_mangement/test_create_dataset.py | 5 +++-- .../test_dataset_mangement/test_update_dataset.py | 4 ++-- 5 files changed, 11 insertions(+), 10 deletions(-) diff --git a/api/utils/validation_utils.py b/api/utils/validation_utils.py index fb2a048849..a22c3f2a35 100644 --- a/api/utils/validation_utils.py +++ b/api/utils/validation_utils.py @@ -652,8 +652,8 @@ class CreateDatasetReq(Base): @classmethod def validate_chunk_method(cls, v: Any, handler) -> Any: """Wrap validation to unify error messages, including type errors (e.g. list).""" - allowed = {"naive", "book", "email", "laws", "manual", "one", "paper", "picture", "presentation", "qa", "table", "tag"} - error_msg = "Input should be 'naive', 'book', 'email', 'laws', 'manual', 'one', 'paper', 'picture', 'presentation', 'qa', 'table' or 'tag'" + allowed = {"naive", "book", "email", "laws", "manual", "one", "paper", "picture", "presentation", "qa", "table", "tag", "resume"} + error_msg = "Input should be 'naive', 'book', 'email', 'laws', 'manual', 'one', 'paper', 'picture', 'presentation', 'qa', 'table', 'tag' or 'resume'" # Omitted field: handler won't be invoked (wrap still gets value); None treated as explicit invalid if v is None: raise PydanticCustomError("literal_error", error_msg) diff --git a/test/testcases/test_http_api/test_dataset_management/test_create_dataset.py b/test/testcases/test_http_api/test_dataset_management/test_create_dataset.py index 45c48ee1e7..5a01155afb 100644 --- a/test/testcases/test_http_api/test_dataset_management/test_create_dataset.py +++ b/test/testcases/test_http_api/test_dataset_management/test_create_dataset.py @@ -381,7 +381,7 @@ class TestDatasetCreate: payload = {"name": name, "chunk_method": chunk_method} res = create_dataset(HttpApiAuth, payload) assert res["code"] == 101, res - assert "Input should be 'naive', 'book', 'email', 'laws', 'manual', 'one', 'paper', 'picture', 'presentation', 'qa', 'table' or 'tag'" in res["message"], res + assert "Input should be 'naive', 'book', 'email', 'laws', 'manual', 'one', 'paper', 'picture', 'presentation', 'qa', 'table', 'tag' or 'resume'" in res["message"], res @pytest.mark.p2 def test_chunk_method_unset(self, HttpApiAuth): @@ -395,7 +395,7 @@ class TestDatasetCreate: payload = {"name": "chunk_method_none", "chunk_method": None} res = create_dataset(HttpApiAuth, payload) assert res["code"] == 101, res - assert "Input should be 'naive', 'book', 'email', 'laws', 'manual', 'one', 'paper', 'picture', 'presentation', 'qa', 'table' or 'tag'" in res["message"], res + assert "Input should be 'naive', 'book', 'email', 'laws', 'manual', 'one', 'paper', 'picture', 'presentation', 'qa', 'table', 'tag' or 'resume'" in res["message"], res @pytest.mark.p1 @pytest.mark.parametrize( diff --git a/test/testcases/test_http_api/test_dataset_management/test_update_dataset.py b/test/testcases/test_http_api/test_dataset_management/test_update_dataset.py index 81d948abcd..58885a5395 100644 --- a/test/testcases/test_http_api/test_dataset_management/test_update_dataset.py +++ b/test/testcases/test_http_api/test_dataset_management/test_update_dataset.py @@ -460,7 +460,7 @@ class TestDatasetUpdate: payload = {"chunk_method": chunk_method} res = update_dataset(HttpApiAuth, dataset_id, payload) assert res["code"] == 101, res - assert "Input should be 'naive', 'book', 'email', 'laws', 'manual', 'one', 'paper', 'picture', 'presentation', 'qa', 'table' or 'tag'" in res["message"], res + assert "Input should be 'naive', 'book', 'email', 'laws', 'manual', 'one', 'paper', 'picture', 'presentation', 'qa', 'table', 'tag' or 'resume'" in res["message"], res @pytest.mark.p3 def test_chunk_method_none(self, HttpApiAuth, add_dataset_func): @@ -468,7 +468,7 @@ class TestDatasetUpdate: payload = {"chunk_method": None} res = update_dataset(HttpApiAuth, dataset_id, payload) assert res["code"] == 101, res - assert "Input should be 'naive', 'book', 'email', 'laws', 'manual', 'one', 'paper', 'picture', 'presentation', 'qa', 'table' or 'tag'" in res["message"], res + assert "Input should be 'naive', 'book', 'email', 'laws', 'manual', 'one', 'paper', 'picture', 'presentation', 'qa', 'table', 'tag' or 'resume'" in res["message"], res @pytest.mark.skipif(os.getenv("DOC_ENGINE") == "infinity", reason="#8208") @pytest.mark.p2 diff --git a/test/testcases/test_sdk_api/test_dataset_mangement/test_create_dataset.py b/test/testcases/test_sdk_api/test_dataset_mangement/test_create_dataset.py index 6b7679544d..8f8f9bfeb6 100644 --- a/test/testcases/test_sdk_api/test_dataset_mangement/test_create_dataset.py +++ b/test/testcases/test_sdk_api/test_dataset_mangement/test_create_dataset.py @@ -306,8 +306,9 @@ class TestDatasetCreate: ("qa", "qa"), ("table", "table"), ("tag", "tag"), + ("resume", "resume") ], - ids=["naive", "book", "email", "laws", "manual", "one", "paper", "picture", "presentation", "qa", "table", "tag"], + ids=["naive", "book", "email", "laws", "manual", "one", "paper", "picture", "presentation", "qa", "table", "tag", "resume"], ) def test_chunk_method(self, client, name, chunk_method): payload = {"name": name, "chunk_method": chunk_method} @@ -327,7 +328,7 @@ class TestDatasetCreate: payload = {"name": name, "chunk_method": chunk_method} with pytest.raises(Exception) as exception_info: client.create_dataset(**payload) - assert "Input should be 'naive', 'book', 'email', 'laws', 'manual', 'one', 'paper', 'picture', 'presentation', 'qa', 'table' or 'tag'" in str(exception_info.value), str(exception_info.value) + assert "Input should be 'naive', 'book', 'email', 'laws', 'manual', 'one', 'paper', 'picture', 'presentation', 'qa', 'table', 'tag' or 'resume'" in str(exception_info.value), str(exception_info.value) @pytest.mark.p2 def test_chunk_method_unset(self, client): diff --git a/test/testcases/test_sdk_api/test_dataset_mangement/test_update_dataset.py b/test/testcases/test_sdk_api/test_dataset_mangement/test_update_dataset.py index 942e3b5fff..6207e31db1 100644 --- a/test/testcases/test_sdk_api/test_dataset_mangement/test_update_dataset.py +++ b/test/testcases/test_sdk_api/test_dataset_mangement/test_update_dataset.py @@ -320,14 +320,14 @@ class TestDatasetUpdate: dataset = add_dataset_func with pytest.raises(Exception) as exception_info: dataset.update({"chunk_method": chunk_method}) - assert "Input should be 'naive', 'book', 'email', 'laws', 'manual', 'one', 'paper', 'picture', 'presentation', 'qa', 'table' or 'tag'" in str(exception_info.value), str(exception_info.value) + assert "Input should be 'naive', 'book', 'email', 'laws', 'manual', 'one', 'paper', 'picture', 'presentation', 'qa', 'table', 'tag' or 'resume'" in str(exception_info.value), str(exception_info.value) @pytest.mark.p3 def test_chunk_method_none(self, add_dataset_func): dataset = add_dataset_func with pytest.raises(Exception) as exception_info: dataset.update({"chunk_method": None}) - assert "Input should be 'naive', 'book', 'email', 'laws', 'manual', 'one', 'paper', 'picture', 'presentation', 'qa', 'table' or 'tag'" in str(exception_info.value), str(exception_info.value) + assert "Input should be 'naive', 'book', 'email', 'laws', 'manual', 'one', 'paper', 'picture', 'presentation', 'qa', 'table', 'tag' or 'resume'" in str(exception_info.value), str(exception_info.value) @pytest.mark.skipif(os.getenv("DOC_ENGINE") == "infinity", reason="#8208") @pytest.mark.p2