mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-07-31 21:13:49 +08:00
Fix: reject empty/space-only content in update_chunk API (#14082)
Closes #6541 ### What problem does this PR solve? Add content validation to `update_chunk` (SDK and non-SDK) to reject empty or whitespace-only content before it reaches the embedding model. **Before:** Calling `update_chunk` with space-only content (like `" "`, `""`, `"\n"`) bypassed validation and was sent directly to the embedding model, which returned an error. This was the same bug previously fixed for `add_chunk` in #6390, but `update_chunk` was missed. **After:** Empty/whitespace-only content is caught by validation and returns an error: `` `content` is required `` ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
@@ -58,7 +58,7 @@ class TestAddChunk:
|
||||
@pytest.mark.parametrize(
|
||||
"payload, expected_code, expected_message",
|
||||
[
|
||||
({"content": None}, 100, """TypeError("unsupported operand type(s) for +: \'NoneType\' and \'str\'")"""),
|
||||
({"content": None}, 102, "`content` is required"),
|
||||
({"content": ""}, 102, "`content` is required"),
|
||||
pytest.param(
|
||||
{"content": 1},
|
||||
|
||||
@@ -48,12 +48,7 @@ class TestUpdatedChunk:
|
||||
"payload, expected_code, expected_message",
|
||||
[
|
||||
pytest.param({"content": None}, 0, "", marks=pytest.mark.skipif(os.getenv("DOC_ENGINE") == "infinity", reason="issues/6509")),
|
||||
pytest.param(
|
||||
{"content": ""},
|
||||
100,
|
||||
"""APIRequestFailedError(\'Error code: 400, with error text {"error":{"code":"1213","message":"未正常接收到prompt参数。"}}\')""",
|
||||
marks=pytest.mark.skip(reason="issues/6541"),
|
||||
),
|
||||
({"content": ""}, 102, "`content` is required"),
|
||||
pytest.param(
|
||||
{"content": 1},
|
||||
100,
|
||||
@@ -61,12 +56,7 @@ class TestUpdatedChunk:
|
||||
marks=pytest.mark.skip,
|
||||
),
|
||||
({"content": "update chunk"}, 0, ""),
|
||||
pytest.param(
|
||||
{"content": " "},
|
||||
100,
|
||||
"""APIRequestFailedError(\'Error code: 400, with error text {"error":{"code":"1213","message":"未正常接收到prompt参数。"}}\')""",
|
||||
marks=pytest.mark.skip(reason="issues/6541"),
|
||||
),
|
||||
({"content": " "}, 102, "`content` is required"),
|
||||
({"content": "\n!?。;!?\"'"}, 0, ""),
|
||||
],
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user