Update document via text API issue, parameter error when updating document content, and unpacking exception. #5965

Closed
opened 2026-02-21 18:13:26 -05:00 by yindo · 7 comments
Owner

Originally created by @glacierck on GitHub (Oct 9, 2024).

Originally assigned to: @JohnJyong, @Yawen-1010 on GitHub.

Self Checks

  • 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 (我已阅读并同意 Language Policy).
  • [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
  • Please do not modify this template :) and fill in all the required fields.

Dify version

0.9.1

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

1、Request example (not submit name):
curl --location --request POST 'https://api.dify.ai/v1/datasets/{dataset_id}/documents/{document_id}/update_by_text' \ --header 'Authorization: Bearer {api_key}' \ --header 'Content-Type: application/json' \ --data-raw '{"text": "text"}'

✔️ Expected Behavior

Complete the update of the text.

The parameter name should be optional, but it is actually required!

Actual Behavior

Server error 500, unknown exception code
File "/app/api/.venv/lib/python3.10/site-packages/flask_restful/__init__.py", line 604, in dispatch_request resp = meth(*args, **kwargs) File "/app/api/controllers/service_api/wraps.py", line 163, in decorated return view(api_token.tenant_id, *args, **kwargs) File "/app/api/controllers/service_api/wraps.py", line 109, in decorated return view(*args, **kwargs) File "/app/api/controllers/service_api/dataset/document.py", line 107, in post upload_file = FileService.upload_text(args.get("text"), args.get("name")) File "/app/api/services/file_service.py", line 114, in upload_text if len(text_name) > 200: TypeError: object of type 'NoneType' has no len()

Originally created by @glacierck on GitHub (Oct 9, 2024). Originally assigned to: @JohnJyong, @Yawen-1010 on GitHub. ### Self Checks - [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 (我已阅读并同意 [Language Policy](https://github.com/langgenius/dify/issues/1542)). - [X] [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:) - [X] Please do not modify this template :) and fill in all the required fields. ### Dify version 0.9.1 ### Cloud or Self Hosted Self Hosted (Docker) ### Steps to reproduce 1、Request example (not submit name): `curl --location --request POST 'https://api.dify.ai/v1/datasets/{dataset_id}/documents/{document_id}/update_by_text' \ --header 'Authorization: Bearer {api_key}' \ --header 'Content-Type: application/json' \ --data-raw '{"text": "text"}'` ### ✔️ Expected Behavior Complete the update of the text. The parameter name should be optional, but it is actually required! ### ❌ Actual Behavior Server error 500, unknown exception code `File "/app/api/.venv/lib/python3.10/site-packages/flask_restful/__init__.py", line 604, in dispatch_request resp = meth(*args, **kwargs) File "/app/api/controllers/service_api/wraps.py", line 163, in decorated return view(api_token.tenant_id, *args, **kwargs) File "/app/api/controllers/service_api/wraps.py", line 109, in decorated return view(*args, **kwargs) File "/app/api/controllers/service_api/dataset/document.py", line 107, in post upload_file = FileService.upload_text(args.get("text"), args.get("name")) File "/app/api/services/file_service.py", line 114, in upload_text if len(text_name) > 200: TypeError: object of type 'NoneType' has no len()`
yindo added the 🐞 bug label 2026-02-21 18:13:26 -05:00
yindo closed this issue 2026-02-21 18:13:26 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Oct 9, 2024):

Hello, @glacierck! I'm here to assist you with any bugs, questions, or contributions. Let's work together to resolve the issue you're facing.

The error you're encountering is due to the name parameter being None, which causes a TypeError when the code tries to calculate its length. To resolve this, ensure that the name parameter is provided in your request.

Here's how you can modify your request to include the name parameter:

curl --location --request POST 'https://api.dify.ai/v1/datasets/{dataset_id}/documents/{document_id}/update_by_text' \
--header 'Authorization: Bearer {api_key}' \
--header 'Content-Type: application/json' \
--data-raw '{"text": "text", "name": "your_document_name"}'

Make sure to replace "your_document_name" with the actual name you want to use for the document. This should prevent the NoneType error [1].

To continue talking to Dosu, mention @dosu.

@dosubot[bot] commented on GitHub (Oct 9, 2024): <!-- Greeting --> Hello, @glacierck! I'm here to assist you with any bugs, questions, or contributions. Let's work together to resolve the issue you're facing. <!-- Answer --> The error you're encountering is due to the `name` parameter being `None`, which causes a `TypeError` when the code tries to calculate its length. To resolve this, ensure that the `name` parameter is provided in your request. Here's how you can modify your request to include the `name` parameter: ```bash curl --location --request POST 'https://api.dify.ai/v1/datasets/{dataset_id}/documents/{document_id}/update_by_text' \ --header 'Authorization: Bearer {api_key}' \ --header 'Content-Type: application/json' \ --data-raw '{"text": "text", "name": "your_document_name"}' ``` Make sure to replace `"your_document_name"` with the actual name you want to use for the document. This should prevent the `NoneType` error <sup>[[1]](https://github.com/langgenius/dify/blob/main/sdks/python-client/dify_client/client.py)</sup>. <!-- Dosu Comment Footer --> *To continue talking to [Dosu](https://dosu.dev), mention @dosu.*
Author
Owner

@glacierck commented on GitHub (Oct 9, 2024):

hi @dosu。The parameter 'name' should be optional and described as such in the document, and it should also be the same in practical applications!

@glacierck commented on GitHub (Oct 9, 2024): hi @dosu。The parameter 'name' should be optional and described as such in the document, and it should also be the same in practical applications!
Author
Owner

@WThirteen commented on GitHub (Oct 9, 2024):

maybe you can use postman or apifox to try connect the url

@WThirteen commented on GitHub (Oct 9, 2024): maybe you can use postman or apifox to try connect the url
Author
Owner

@glacierck commented on GitHub (Oct 9, 2024):

maybe you can use postman or apifox to try connect the url

I have confirmed this exception twice and checked the source code of the interface to confirm the existence of the bug.
image

@glacierck commented on GitHub (Oct 9, 2024): > maybe you can use postman or apifox to try connect the url I have confirmed this exception twice and checked the source code of the interface to confirm the existence of the bug. ![image](https://github.com/user-attachments/assets/1e7c5831-dd73-4e11-b873-aae5fbc76484)
Author
Owner

@WThirteen commented on GitHub (Oct 9, 2024):

好的大哥,很遗憾我也无能为力。
have a nice day

@WThirteen commented on GitHub (Oct 9, 2024): 好的大哥,很遗憾我也无能为力。 have a nice day
Author
Owner

@Yawen-1010 commented on GitHub (Oct 11, 2024):

maybe you can use postman or apifox to try connect the url

I have confirmed this exception twice and checked the source code of the interface to confirm the existence of the bug. image

@JohnJyong

@Yawen-1010 commented on GitHub (Oct 11, 2024): > > maybe you can use postman or apifox to try connect the url > > I have confirmed this exception twice and checked the source code of the interface to confirm the existence of the bug. ![image](https://private-user-images.githubusercontent.com/21599896/374829318-1e7c5831-dd73-4e11-b873-aae5fbc76484.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mjg2NDI0ODUsIm5iZiI6MTcyODY0MjE4NSwicGF0aCI6Ii8yMTU5OTg5Ni8zNzQ4MjkzMTgtMWU3YzU4MzEtZGQ3My00ZTExLWI4NzMtYWFlNWZiYzc2NDg0LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDEwMTElMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQxMDExVDEwMjMwNVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTM5MTY3OGZmZjMwMWNjYzYxZmVkODExYzBmOGU0MTYzOTVlNWJlMjg3NGQ1N2NkZTAwYzZhNDc0YzcyOTllM2QmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.F1qFCyp3AX9z6gCy2ri19WkbJ49KNCRU4domjVLp-7o) @JohnJyong
Author
Owner

@dosubot[bot] commented on GitHub (Nov 11, 2024):

Hi, @glacierck. I'm Dosu, and I'm helping the Dify team manage their backlog. I'm marking this issue as stale.

Issue Summary:

  • A bug in Dify API (version 0.9.1) requires the 'name' parameter, which should be optional.
  • You confirmed the bug by checking the source code.
  • I suggested including the 'name' parameter to avoid errors.
  • @WThirteen recommended testing with Postman or Apifox, but you have already verified the issue.

Next Steps:

  • Please confirm if this issue is still relevant to the latest version of the Dify repository by commenting here.
  • If there is no further activity, this issue will be automatically closed in 15 days.

Thank you for your understanding and contribution!

@dosubot[bot] commented on GitHub (Nov 11, 2024): Hi, @glacierck. I'm [Dosu](https://dosu.dev), and I'm helping the Dify team manage their backlog. I'm marking this issue as stale. **Issue Summary:** - A bug in Dify API (version 0.9.1) requires the 'name' parameter, which should be optional. - You confirmed the bug by checking the source code. - I suggested including the 'name' parameter to avoid errors. - @WThirteen recommended testing with Postman or Apifox, but you have already verified the issue. **Next Steps:** - Please confirm if this issue is still relevant to the latest version of the Dify repository by commenting here. - If there is no further activity, this issue will be automatically closed in 15 days. Thank you for your understanding and contribution!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#5965