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)
This commit is contained in:
Lynn
2026-03-26 19:06:51 +08:00
committed by GitHub
parent 8402fcac6b
commit 6a4a9debd2
5 changed files with 11 additions and 10 deletions

View File

@ -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)

View File

@ -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(

View File

@ -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

View File

@ -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):

View File

@ -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