Error in Calling the create-by-text API of Dify Version 1.9 {"message": "Internal Server Error","code": "unknown","status": 500} #19849

Closed
opened 2026-02-21 20:04:32 -05:00 by yindo · 5 comments
Owner

Originally created by @wangdi980817-lang on GitHub (Oct 23, 2025).

Self Checks

  • I have read the Contributing Guide and Language Policy.
  • This is only for bug report, if you would like to ask a question, please head to Discussions.
  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report, otherwise it will be closed.
  • 【中文用户 & Non English User】请使用英语提交,否则会被关闭 :)
  • Please do not modify this template :) and fill in all the required fields.

Dify version

1.9

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

body中的内容:{
"name": "测试清单",
"text": "该智能体是负责提取SGS检测报告中的各个检测项目的信息,各个检测项目在报告中是以表格形式展示的,该智能体采用了Qwen2.5-VL-32B模型,先通过文档提取器将pdf文档中的内容解析出来,然后交给大模型进行关键信息提取,编写提示词按照规定输出格式输出。",
"indexing_technique": "high_quality",
"embedding_model": "Qwen3-Embedding-8B",
"embedding_model_provider": "langgenius/xinference/xinference"
}

✔️ Expected Behavior

请问有啥解决办法吗

Actual Behavior

No response

Originally created by @wangdi980817-lang on GitHub (Oct 23, 2025). ### Self Checks - [x] I have read the [Contributing Guide](https://github.com/langgenius/dify/blob/main/CONTRIBUTING.md) and [Language Policy](https://github.com/langgenius/dify/issues/1542). - [x] This is only for bug report, if you would like to ask a question, please head to [Discussions](https://github.com/langgenius/dify/discussions/categories/general). - [x] I have searched for existing issues [search for existing issues](https://github.com/langgenius/dify/issues), including closed ones. - [x] I confirm that I am using English to submit this report, otherwise it will be closed. - [x] 【中文用户 & Non English User】请使用英语提交,否则会被关闭 :) - [x] Please do not modify this template :) and fill in all the required fields. ### Dify version 1.9 ### Cloud or Self Hosted Self Hosted (Docker) ### Steps to reproduce body中的内容:{ "name": "测试清单", "text": "该智能体是负责提取SGS检测报告中的各个检测项目的信息,各个检测项目在报告中是以表格形式展示的,该智能体采用了Qwen2.5-VL-32B模型,先通过文档提取器将pdf文档中的内容解析出来,然后交给大模型进行关键信息提取,编写提示词按照规定输出格式输出。", "indexing_technique": "high_quality", "embedding_model": "Qwen3-Embedding-8B", "embedding_model_provider": "langgenius/xinference/xinference" } ### ✔️ Expected Behavior 请问有啥解决办法吗 ### ❌ Actual Behavior _No response_
yindo added the 🐞 bug🤔 cant-reproduce labels 2026-02-21 20:04:32 -05:00
yindo closed this issue 2026-02-21 20:04:32 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Oct 23, 2025):

Hi @wangdi980817-lang! I'm Dosu and I’m helping the dify team.

A 500 Internal Server Error from the create-by-text API in Dify (self-hosted, Docker) with xinference and Qwen models is often caused by connectivity or configuration issues between Dify and the xinference service, or by embedding model/provider misconfiguration.

Here’s a focused troubleshooting checklist:

  1. Xinference Service Accessibility: Make sure xinference is running and listening on all interfaces (xinference-local -H 0.0.0.0). In your Dify model provider settings, use your host machine’s IP address (not 127.0.0.1) for the xinference server URL, e.g., http://192.168.x.x:9997. Docker containers cannot access services on 127.0.0.1 of the host by default. If host.docker.internal is supported on your OS, you can use that as well citation citation.

  2. Model Configuration: Double-check that the Qwen2.5-VL-32B and Qwen3-Embedding-8B models are correctly deployed and accessible in xinference. In Dify, the model UID and provider info must match what xinference exposes.

  3. Provider Token and Credentials: If the provider token or credentials for xinference are missing or invalid, Dify will throw a 500 error. Make sure the provider is fully initialized in Dify’s settings citation.

  4. Logs: Check the logs for both the Dify API container and the xinference service. Look for errors about connection timeouts, missing models, or provider initialization failures. Use docker-compose logs api and check xinference’s output for clues.

  5. Required Parameters: The API expects all required fields (name, text, indexing_technique, embedding_model, embedding_model_provider) to be set and non-null. Missing or None values will cause a 500 error citation.

  6. Model Disabled: If the model you reference is disabled or deleted in Dify, you’ll get a 500 error. Make sure the model is active in your Dify settings citation.

  7. Network/Firewall: Ensure Docker networking and firewall rules allow the API container to reach the xinference host and port.

If you still get a 500 error after these checks, please share the relevant error logs from the Dify API container and xinference service for more targeted help.

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other  Chat with Dosu Join Discord Share on X

@dosubot[bot] commented on GitHub (Oct 23, 2025): <!-- Greeting --> Hi @wangdi980817-lang! I'm [Dosu](https://go.dosu.dev/dosubot) and I’m helping the dify team. <!-- Answer --> A 500 Internal Server Error from the create-by-text API in Dify (self-hosted, Docker) with xinference and Qwen models is often caused by connectivity or configuration issues between Dify and the xinference service, or by embedding model/provider misconfiguration. Here’s a focused troubleshooting checklist: 1. **Xinference Service Accessibility**: Make sure xinference is running and listening on all interfaces (`xinference-local -H 0.0.0.0`). In your Dify model provider settings, use your host machine’s IP address (not `127.0.0.1`) for the xinference server URL, e.g., `http://192.168.x.x:9997`. Docker containers cannot access services on `127.0.0.1` of the host by default. If `host.docker.internal` is supported on your OS, you can use that as well [citation](https://github.com/langgenius/dify/issues/18308#issuecomment-2812434985) [citation](https://github.com/langgenius/dify/issues/16585). 2. **Model Configuration**: Double-check that the Qwen2.5-VL-32B and Qwen3-Embedding-8B models are correctly deployed and accessible in xinference. In Dify, the model UID and provider info must match what xinference exposes. 3. **Provider Token and Credentials**: If the provider token or credentials for xinference are missing or invalid, Dify will throw a 500 error. Make sure the provider is fully initialized in Dify’s settings [citation](https://github.com/langgenius/dify/blob/92c81b1833a42d745278f5c0bbd78446e96ed9d9/api/services/dataset_service.py). 4. **Logs**: Check the logs for both the Dify API container and the xinference service. Look for errors about connection timeouts, missing models, or provider initialization failures. Use `docker-compose logs api` and check xinference’s output for clues. 5. **Required Parameters**: The API expects all required fields (`name`, `text`, `indexing_technique`, `embedding_model`, `embedding_model_provider`) to be set and non-null. Missing or `None` values will cause a 500 error [citation](https://github.com/langgenius/dify/blob/92c81b1833a42d745278f5c0bbd78446e96ed9d9/api/controllers/service_api/dataset/document.py). 6. **Model Disabled**: If the model you reference is disabled or deleted in Dify, you’ll get a 500 error. Make sure the model is active in your Dify settings [citation](https://github.com/langgenius/dify/issues/24737). 7. **Network/Firewall**: Ensure Docker networking and firewall rules allow the API container to reach the xinference host and port. If you still get a 500 error after these checks, please share the relevant error logs from the Dify API container and xinference service for more targeted help. <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/a7e52b93-7368-49ec-bd03-8b010b08423f?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/a7e52b93-7368-49ec-bd03-8b010b08423f?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/a7e52b93-7368-49ec-bd03-8b010b08423f?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/a7e52b93-7368-49ec-bd03-8b010b08423f?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/a7e52b93-7368-49ec-bd03-8b010b08423f?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/a7e52b93-7368-49ec-bd03-8b010b08423f?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/a7e52b93-7368-49ec-bd03-8b010b08423f?feedback_type=other)</sup>&nbsp;&nbsp;[![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/6088a4f4-073a-43f3-b3d4-4f06fb0c05a0/ask?utm_source=github)&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/langgenius/dify/issues/27330)
Author
Owner

@wangdi980817-lang commented on GitHub (Oct 23, 2025):

看了下日志,报了这个错误
2025-10-23 06:28:29.783 ERROR [Dummy-3] [app.py:875] - Exception on /v1/datasets/dfd1874f-f9aa-4b49-8c3d-8ac673db66ca/document/create-by-text [POST]
docker-api-1 | Traceback (most recent call last):
docker-api-1 | File "/app/api/.venv/lib/python3.12/site-packages/flask/app.py", line 917, in full_dispatch_request
docker-api-1 | rv = self.dispatch_request()
docker-api-1 | ^^^^^^^^^^^^^^^^^^^^^^^
docker-api-1 | File "/app/api/.venv/lib/python3.12/site-packages/flask/app.py", line 902, in dispatch_request
docker-api-1 | return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args) # type: ignore[no-any-return]
docker-api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
docker-api-1 | File "/app/api/.venv/lib/python3.12/site-packages/flask_restx/api.py", line 402, in wrapper
docker-api-1 | resp = resource(*args, **kwargs)
docker-api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^
docker-api-1 | File "/app/api/.venv/lib/python3.12/site-packages/flask/views.py", line 110, in view
docker-api-1 | return current_app.ensure_sync(self.dispatch_request)(**kwargs) # type: ignore[no-any-return]
docker-api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
docker-api-1 | File "/app/api/.venv/lib/python3.12/site-packages/flask_restx/resource.py", line 41, in dispatch_request
docker-api-1 | resp = meth(*args, **kwargs)
docker-api-1 | ^^^^^^^^^^^^^^^^^^^^^
docker-api-1 | File "/app/api/controllers/service_api/wraps.py", line 258, in decorated
docker-api-1 | return view(api_token.tenant_id, *args, **kwargs)
docker-api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
docker-api-1 | File "/app/api/controllers/service_api/wraps.py", line 126, in decorated
docker-api-1 | return view(*args, **kwargs)
docker-api-1 | ^^^^^^^^^^^^^^^^^^^^^
docker-api-1 | File "/app/api/controllers/service_api/wraps.py", line 126, in decorated
docker-api-1 | return view(*args, **kwargs)
docker-api-1 | ^^^^^^^^^^^^^^^^^^^^^
docker-api-1 | File "/app/api/controllers/service_api/wraps.py", line 185, in decorated
docker-api-1 | return view(*args, **kwargs)
docker-api-1 | ^^^^^^^^^^^^^^^^^^^^^
docker-api-1 | File "/app/api/controllers/service_api/dataset/document.py", line 147, in post
docker-api-1 | documents, batch = DocumentService.save_document_with_dataset_id(
docker-api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
docker-api-1 | File "/app/api/services/dataset_service.py", line 1574, in save_document_with_dataset_id
docker-api-1 | dataset_process_rule.id, # type: ignore
docker-api-1 | ^^^^^^^^^^^^^^^^^^^^^^^
docker-api-1 | AttributeError: 'NoneType' object has no attribute 'id'
docker-api-1 | 2025-10-23 06:28:29.804 ERROR [Dummy-3] [app.py:875] - Exception on /v1/datasets/dfd1874f-f9aa-4b49-8c3d-8ac673db66ca/document/create-by-text [POST]
docker-api-1 | Traceback (most recent call last):
docker-api-1 | File "/app/api/.venv/lib/python3.12/site-packages/flask/app.py", line 917, in full_dispatch_request
docker-api-1 | rv = self.dispatch_request()
docker-api-1 | ^^^^^^^^^^^^^^^^^^^^^^^
docker-api-1 | File "/app/api/.venv/lib/python3.12/site-packages/flask/app.py", line 902, in dispatch_request
docker-api-1 | return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args) # type: ignore[no-any-return]
docker-api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
docker-api-1 | File "/app/api/.venv/lib/python3.12/site-packages/flask_restx/api.py", line 402, in wrapper
docker-api-1 | resp = resource(*args, **kwargs)
docker-api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^
docker-api-1 | File "/app/api/.venv/lib/python3.12/site-packages/flask/views.py", line 110, in view
docker-api-1 | return current_app.ensure_sync(self.dispatch_request)(**kwargs) # type: ignore[no-any-return]
docker-api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
docker-api-1 | File "/app/api/.venv/lib/python3.12/site-packages/flask_restx/resource.py", line 41, in dispatch_request
docker-api-1 | resp = meth(*args, **kwargs)
docker-api-1 | ^^^^^^^^^^^^^^^^^^^^^
docker-api-1 | File "/app/api/controllers/service_api/wraps.py", line 258, in decorated
docker-api-1 | return view(api_token.tenant_id, *args, **kwargs)
docker-api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
docker-api-1 | File "/app/api/controllers/service_api/wraps.py", line 126, in decorated
docker-api-1 | return view(*args, **kwargs)
docker-api-1 | ^^^^^^^^^^^^^^^^^^^^^
docker-api-1 | File "/app/api/controllers/service_api/wraps.py", line 126, in decorated
docker-api-1 | return view(*args, **kwargs)
docker-api-1 | ^^^^^^^^^^^^^^^^^^^^^
docker-api-1 | File "/app/api/controllers/service_api/wraps.py", line 185, in decorated
docker-api-1 | return view(*args, **kwargs)
docker-api-1 | ^^^^^^^^^^^^^^^^^^^^^
docker-api-1 | File "/app/api/controllers/service_api/dataset/document.py", line 147, in post
docker-api-1 | documents, batch = DocumentService.save_document_with_dataset_id(
docker-api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
docker-api-1 | File "/app/api/services/dataset_service.py", line 1574, in save_document_with_dataset_id
docker-api-1 | dataset_process_rule.id, # type: ignore
docker-api-1 | ^^^^^^^^^^^^^^^^^^^^^^^
docker-api-1 | AttributeError: 'NoneType' object has no attribute 'id'

@wangdi980817-lang commented on GitHub (Oct 23, 2025): 看了下日志,报了这个错误 2025-10-23 06:28:29.783 ERROR [Dummy-3] [app.py:875] - Exception on /v1/datasets/dfd1874f-f9aa-4b49-8c3d-8ac673db66ca/document/create-by-text [POST] docker-api-1 | Traceback (most recent call last): docker-api-1 | File "/app/api/.venv/lib/python3.12/site-packages/flask/app.py", line 917, in full_dispatch_request docker-api-1 | rv = self.dispatch_request() docker-api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ docker-api-1 | File "/app/api/.venv/lib/python3.12/site-packages/flask/app.py", line 902, in dispatch_request docker-api-1 | return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args) # type: ignore[no-any-return] docker-api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ docker-api-1 | File "/app/api/.venv/lib/python3.12/site-packages/flask_restx/api.py", line 402, in wrapper docker-api-1 | resp = resource(*args, **kwargs) docker-api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ docker-api-1 | File "/app/api/.venv/lib/python3.12/site-packages/flask/views.py", line 110, in view docker-api-1 | return current_app.ensure_sync(self.dispatch_request)(**kwargs) # type: ignore[no-any-return] docker-api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ docker-api-1 | File "/app/api/.venv/lib/python3.12/site-packages/flask_restx/resource.py", line 41, in dispatch_request docker-api-1 | resp = meth(*args, **kwargs) docker-api-1 | ^^^^^^^^^^^^^^^^^^^^^ docker-api-1 | File "/app/api/controllers/service_api/wraps.py", line 258, in decorated docker-api-1 | return view(api_token.tenant_id, *args, **kwargs) docker-api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ docker-api-1 | File "/app/api/controllers/service_api/wraps.py", line 126, in decorated docker-api-1 | return view(*args, **kwargs) docker-api-1 | ^^^^^^^^^^^^^^^^^^^^^ docker-api-1 | File "/app/api/controllers/service_api/wraps.py", line 126, in decorated docker-api-1 | return view(*args, **kwargs) docker-api-1 | ^^^^^^^^^^^^^^^^^^^^^ docker-api-1 | File "/app/api/controllers/service_api/wraps.py", line 185, in decorated docker-api-1 | return view(*args, **kwargs) docker-api-1 | ^^^^^^^^^^^^^^^^^^^^^ docker-api-1 | File "/app/api/controllers/service_api/dataset/document.py", line 147, in post docker-api-1 | documents, batch = DocumentService.save_document_with_dataset_id( docker-api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ docker-api-1 | File "/app/api/services/dataset_service.py", line 1574, in save_document_with_dataset_id docker-api-1 | dataset_process_rule.id, # type: ignore docker-api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ docker-api-1 | AttributeError: 'NoneType' object has no attribute 'id' docker-api-1 | 2025-10-23 06:28:29.804 ERROR [Dummy-3] [app.py:875] - Exception on /v1/datasets/dfd1874f-f9aa-4b49-8c3d-8ac673db66ca/document/create-by-text [POST] docker-api-1 | Traceback (most recent call last): docker-api-1 | File "/app/api/.venv/lib/python3.12/site-packages/flask/app.py", line 917, in full_dispatch_request docker-api-1 | rv = self.dispatch_request() docker-api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ docker-api-1 | File "/app/api/.venv/lib/python3.12/site-packages/flask/app.py", line 902, in dispatch_request docker-api-1 | return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args) # type: ignore[no-any-return] docker-api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ docker-api-1 | File "/app/api/.venv/lib/python3.12/site-packages/flask_restx/api.py", line 402, in wrapper docker-api-1 | resp = resource(*args, **kwargs) docker-api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ docker-api-1 | File "/app/api/.venv/lib/python3.12/site-packages/flask/views.py", line 110, in view docker-api-1 | return current_app.ensure_sync(self.dispatch_request)(**kwargs) # type: ignore[no-any-return] docker-api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ docker-api-1 | File "/app/api/.venv/lib/python3.12/site-packages/flask_restx/resource.py", line 41, in dispatch_request docker-api-1 | resp = meth(*args, **kwargs) docker-api-1 | ^^^^^^^^^^^^^^^^^^^^^ docker-api-1 | File "/app/api/controllers/service_api/wraps.py", line 258, in decorated docker-api-1 | return view(api_token.tenant_id, *args, **kwargs) docker-api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ docker-api-1 | File "/app/api/controllers/service_api/wraps.py", line 126, in decorated docker-api-1 | return view(*args, **kwargs) docker-api-1 | ^^^^^^^^^^^^^^^^^^^^^ docker-api-1 | File "/app/api/controllers/service_api/wraps.py", line 126, in decorated docker-api-1 | return view(*args, **kwargs) docker-api-1 | ^^^^^^^^^^^^^^^^^^^^^ docker-api-1 | File "/app/api/controllers/service_api/wraps.py", line 185, in decorated docker-api-1 | return view(*args, **kwargs) docker-api-1 | ^^^^^^^^^^^^^^^^^^^^^ docker-api-1 | File "/app/api/controllers/service_api/dataset/document.py", line 147, in post docker-api-1 | documents, batch = DocumentService.save_document_with_dataset_id( docker-api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ docker-api-1 | File "/app/api/services/dataset_service.py", line 1574, in save_document_with_dataset_id docker-api-1 | dataset_process_rule.id, # type: ignore docker-api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ docker-api-1 | AttributeError: 'NoneType' object has no attribute 'id'
Author
Owner

@dosubot[bot] commented on GitHub (Oct 23, 2025):

你的报错 AttributeError: 'NoneType' object has no attribute 'id' 是因为 Dify 在处理 create-by-text API 时,dataset_process_rule 没有被正确设置,导致它是 None,然后代码里又直接访问了 .id 属性。

根本原因是:你的数据集(dataset)没有配置有效的“处理规则(process rule)”,或者 API 请求体里没有带上 process_rule,且数据库里也没有历史规则。Dify 代码期望每个数据集都至少有一个 process rule,否则就会报这个错(参考源码)。

解决办法:

  1. 确认你的数据集已经有 process rule。可以在 Dify 控制台里编辑数据集,设置分段方式、预处理规则等,保存后再试。
  2. 如果你是通过 API 创建数据集或文档,body 里要带上 process_rule 字段,内容类似:
    "process_rule": {
      "mode": "automatic"
    }
    
    或者自定义分段规则(mode: custom/hierarchical),并带上 rules。
  3. 如果数据集是新建的,第一次上传文档时一定要带 process_rule,否则 Dify 没法自动推断,最终会报 NoneType 错误。

参考代码片段:

  • 如果没有 process_rule,Dify 会尝试用历史规则(dataset.latest_process_rule),如果还是没有,就会报错 源码
  • API 入口也有类似判断 源码

建议:
优先在控制台配置好数据集的分段规则。如果必须用 API,确保 body 里带上 process_rule 字段。这样就不会再遇到 NoneType 的报错了。

如需示例 process_rule 或有其他配置问题,可以补充说明。

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other  Chat with Dosu Join Discord Share on X

@dosubot[bot] commented on GitHub (Oct 23, 2025): <!-- Answer --> 你的报错 `AttributeError: 'NoneType' object has no attribute 'id'` 是因为 Dify 在处理 create-by-text API 时,`dataset_process_rule` 没有被正确设置,导致它是 None,然后代码里又直接访问了 `.id` 属性。 根本原因是:你的数据集(dataset)没有配置有效的“处理规则(process rule)”,或者 API 请求体里没有带上 process_rule,且数据库里也没有历史规则。Dify 代码期望每个数据集都至少有一个 process rule,否则就会报这个错([参考源码](https://github.com/langgenius/dify/blob/92c81b1833a42d745278f5c0bbd78446e96ed9d9/api/services/dataset_service.py))。 **解决办法:** 1. 确认你的数据集已经有 process rule。可以在 Dify 控制台里编辑数据集,设置分段方式、预处理规则等,保存后再试。 2. 如果你是通过 API 创建数据集或文档,body 里要带上 `process_rule` 字段,内容类似: ```json "process_rule": { "mode": "automatic" } ``` 或者自定义分段规则(mode: custom/hierarchical),并带上 rules。 3. 如果数据集是新建的,第一次上传文档时一定要带 process_rule,否则 Dify 没法自动推断,最终会报 NoneType 错误。 **参考代码片段:** - 如果没有 process_rule,Dify 会尝试用历史规则(dataset.latest_process_rule),如果还是没有,就会报错 [源码](https://github.com/langgenius/dify/blob/92c81b1833a42d745278f5c0bbd78446e96ed9d9/api/services/dataset_service.py)。 - API 入口也有类似判断 [源码](https://github.com/langgenius/dify/blob/92c81b1833a42d745278f5c0bbd78446e96ed9d9/api/controllers/service_api/dataset/document.py)。 **建议:** 优先在控制台配置好数据集的分段规则。如果必须用 API,确保 body 里带上 process_rule 字段。这样就不会再遇到 NoneType 的报错了。 如需示例 process_rule 或有其他配置问题,可以补充说明。 <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/14756c8a-46a4-47f6-a44a-eb9dd1317a20?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/14756c8a-46a4-47f6-a44a-eb9dd1317a20?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/14756c8a-46a4-47f6-a44a-eb9dd1317a20?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/14756c8a-46a4-47f6-a44a-eb9dd1317a20?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/14756c8a-46a4-47f6-a44a-eb9dd1317a20?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/14756c8a-46a4-47f6-a44a-eb9dd1317a20?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/14756c8a-46a4-47f6-a44a-eb9dd1317a20?feedback_type=other)</sup>&nbsp;&nbsp;[![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/6088a4f4-073a-43f3-b3d4-4f06fb0c05a0/ask?utm_source=github)&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/langgenius/dify/issues/27330)
Author
Owner

@crazywoola commented on GitHub (Oct 23, 2025):

Please upgrade to the latest version.

@crazywoola commented on GitHub (Oct 23, 2025): Please upgrade to the latest version.
Author
Owner

@wangdi980817-lang commented on GitHub (Oct 24, 2025):

在调用该接口创建文档时,没办法正常切片,一直都只能生成一个块,调用参数如下:
{
"name": "测试清单",
"text": "CHIPGOO ELECTRONICS LIMITED(香港)\nMAGELLANIC PHOENIX MARINE AND TRADING LIMITED\nMAXTRONIC GLOBAL LIMITED(香港)",
"indexing_technique": "high_quality",
"embedding_model": "Qwen3-Embedding-8B",
"embedding_model_provider": "langgenius/xinference/xinference",
"doc_form": "text_model",
"process_rule": {
"mode": "automatic",
"rules": {
"pre_processing_rules": [
{"id": "remove_extra_spaces", "enabled": true}
],
"segmentation": {
"separator": "\n",
"max_tokens": 512
}
}
}
}

@wangdi980817-lang commented on GitHub (Oct 24, 2025): 在调用该接口创建文档时,没办法正常切片,一直都只能生成一个块,调用参数如下: { "name": "测试清单", "text": "CHIPGOO ELECTRONICS LIMITED(香港)\nMAGELLANIC PHOENIX MARINE AND TRADING LIMITED\nMAXTRONIC GLOBAL LIMITED(香港)", "indexing_technique": "high_quality", "embedding_model": "Qwen3-Embedding-8B", "embedding_model_provider": "langgenius/xinference/xinference", "doc_form": "text_model", "process_rule": { "mode": "automatic", "rules": { "pre_processing_rules": [ {"id": "remove_extra_spaces", "enabled": true} ], "segmentation": { "separator": "\n", "max_tokens": 512 } } } }
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#19849