Skip to content

[Bug]: HTTP API add_chunk:Space-only strings in questions list cause backend model errors #6404

@asiroliu

Description

@asiroliu

Self Checks

  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report (Language Policy).
  • Non-english title submitions will be closed directly ( 非英文标题的提交将会被直接关闭 ) (Language Policy).
  • Please do not modify this template :) and fill in all the required fields.

RAGFlow workspace code commit ID

x

RAGFlow image version

018457a19395(infiniflow/ragflow:nightly)

Other environment information

Actual behavior

Space-only strings in questions list cause backend model errors

Expected behavior

No response

Steps to reproduce

1. Send a POST request with Space-only questions list:

payload = {"content": "a", "questions": [" "]}
response = requests.post(f'http://127.0.0.1:9380/api/v1/datasets/<dataset_id>/documents/<document_id>/chunks', json=payload)

2. Observe the API response:

{'code': 100, 'data': None, 'message': 'APIRequestFailedError(\'Error code: 400, with error text {"error":{"code":"1213","message":"未正常接收到prompt参数。"}}\')'}

3. ragflow log:

2025-03-21 17:24:47,311 ERROR    24 Error code: 400, with error text {"error":{"code":"1213","message":"未正常接收到prompt参数。"}}
Traceback (most recent call last):
  File "/ragflow/.venv/lib/python3.10/site-packages/flask/app.py", line 880, in full_dispatch_request
    rv = self.dispatch_request()
  File "/ragflow/.venv/lib/python3.10/site-packages/flask/app.py", line 865, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]
  File "/ragflow/api/utils/api_utils.py", line 303, in decorated_function
    return func(*args, **kwargs)
  File "/ragflow/api/apps/sdk/doc.py", line 1083, in add_chunk
    v, c = embd_mdl.encode([doc.name, req["content"] if not d["question_kwd"] else "\n".join(d["question_kwd"])])
  File "<@beartype(rag.llm.embedding_model.ZhipuEmbed.encode) at 0x701b324e9fc0>", line 31, in encode
  File "/ragflow/rag/llm/embedding_model.py", line 241, in encode
    res = self.client.embeddings.create(input=txt,
  File "/ragflow/.venv/lib/python3.10/site-packages/zhipuai/api_resource/embeddings.py", line 35, in create
    return self._post(
  File "/ragflow/.venv/lib/python3.10/site-packages/zhipuai/core/_http_client.py", line 292, in post
    return self.request(
  File "/ragflow/.venv/lib/python3.10/site-packages/zhipuai/core/_http_client.py", line 251, in request
    raise self._make_status_error(err.response) from None
zhipuai.core._errors.APIRequestFailedError: Error code: 400, with error text {"error":{"code":"1213","message":"未正常接收到prompt参数。"}}

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    ✅ verified🐞 bugSomething isn't working, pull request that fix bug.

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions