Internal Server Error occurs when trying to re-save existing Knowledge #6465

Closed
opened 2026-02-21 18:15:52 -05:00 by yindo · 1 comment
Owner

Originally created by @gakugaku on GitHub (Oct 31, 2024).

Originally assigned to: @JohnJyong 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.10.2

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

  1. Select an existing knowledge item to navigate to the document screen.
  2. In the document view, select “Segment Settings” from the “...” menu for the file.
  3. At the bottom of the “Text Preprocessing and Cleaning” screen, click “Save and Process.”
  4. An “Internal Server Error” message appears at the top right.
    image

✔️ Expected Behavior

The item should save successfully with the applied settings.

Actual Behavior

An Internal Server Error occurs. Below is the relevant Docker Dify API log output
docker container logs dify-api-1

2024-10-31 03:09:57,221.221 ERROR [Dummy-1180] [app.py:838] - Exception on /console/api/datasets/06363366305/documents [POST]
Traceback (most recent call last):
  File "/app/api/.venv/lib/python3.10/site-packages/flask/app.py", line 880, in full_dispatch_request
    rv = self.dispatch_request()
  File "/app/api/.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 "/app/api/.venv/lib/python3.10/site-packages/flask_restful/__init__.py", line 489, in wrapper
    resp = resource(*args, **kwargs)
  File "/app/api/.venv/lib/python3.10/site-packages/flask/views.py", line 110, in view
    return current_app.ensure_sync(self.dispatch_request)(**kwargs)  # type: ignore[no-any-return]
  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/console/setup.py", line 65, in decorated
    return view(*args, **kwargs)
  File "/app/api/libs/login.py", line 92, in decorated_view
    return current_app.ensure_sync(func)(*args, **kwargs)
  File "/app/api/controllers/console/wraps.py", line 22, in decorated
    return view(*args, **kwargs)
  File "/app/api/.venv/lib/python3.10/site-packages/flask_restful/__init__.py", line 696, in wrapper
    resp = f(*args, **kwargs)
  File "/app/api/controllers/console/wraps.py", line 81, in decorated
    return view(*args, **kwargs)
  File "/app/api/controllers/console/datasets/datasets_document.py", line 266, in post
    documents, batch = DocumentService.save_document_with_dataset_id(dataset, args, current_user)
TypeError: cannot unpack non-iterable NoneType object
Originally created by @gakugaku on GitHub (Oct 31, 2024). Originally assigned to: @JohnJyong 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.10.2 ### Cloud or Self Hosted Self Hosted (Docker) ### Steps to reproduce 1. Select an existing knowledge item to navigate to the document screen. 2. In the document view, select “Segment Settings” from the “...” menu for the file. 3. At the bottom of the “Text Preprocessing and Cleaning” screen, click “Save and Process.” 4. An “Internal Server Error” message appears at the top right. ![image](https://github.com/user-attachments/assets/1c9c8b99-2331-435d-8beb-0b9e3fdd7d64) ### ✔️ Expected Behavior The item should save successfully with the applied settings. ### ❌ Actual Behavior An Internal Server Error occurs. Below is the relevant Docker Dify API log output `docker container logs dify-api-1` ```shellsession 2024-10-31 03:09:57,221.221 ERROR [Dummy-1180] [app.py:838] - Exception on /console/api/datasets/06363366305/documents [POST] Traceback (most recent call last): File "/app/api/.venv/lib/python3.10/site-packages/flask/app.py", line 880, in full_dispatch_request rv = self.dispatch_request() File "/app/api/.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 "/app/api/.venv/lib/python3.10/site-packages/flask_restful/__init__.py", line 489, in wrapper resp = resource(*args, **kwargs) File "/app/api/.venv/lib/python3.10/site-packages/flask/views.py", line 110, in view return current_app.ensure_sync(self.dispatch_request)(**kwargs) # type: ignore[no-any-return] 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/console/setup.py", line 65, in decorated return view(*args, **kwargs) File "/app/api/libs/login.py", line 92, in decorated_view return current_app.ensure_sync(func)(*args, **kwargs) File "/app/api/controllers/console/wraps.py", line 22, in decorated return view(*args, **kwargs) File "/app/api/.venv/lib/python3.10/site-packages/flask_restful/__init__.py", line 696, in wrapper resp = f(*args, **kwargs) File "/app/api/controllers/console/wraps.py", line 81, in decorated return view(*args, **kwargs) File "/app/api/controllers/console/datasets/datasets_document.py", line 266, in post documents, batch = DocumentService.save_document_with_dataset_id(dataset, args, current_user) TypeError: cannot unpack non-iterable NoneType object ```
yindo added the 🐞 bug label 2026-02-21 18:15:52 -05:00
yindo closed this issue 2026-02-21 18:15:52 -05:00
Author
Owner

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

Hey, @gakugaku! I'm here to help you with any bugs, questions, or contributions you have for the Dify project. Let me know how I can assist you!

The error you're encountering, "TypeError: cannot unpack non-iterable NoneType object," suggests that the DocumentService.save_document_with_dataset_id function is returning None instead of the expected tuple of documents and batch. This could happen if the function encounters an error or a condition where it doesn't return the expected values.

Here are a few steps you can take to troubleshoot and resolve this issue:

  1. Check for Exceptions: Ensure that the function is not encountering an exception that causes it to return None. Review the function's implementation to see if there are any conditions or exceptions that might lead to this behavior.

  2. Review Function Logic: Verify the logic within DocumentService.save_document_with_dataset_id to ensure it correctly handles all input scenarios and returns the expected tuple.

  3. Logging: Add logging within the function to trace its execution path and identify where it might be returning None.

  4. Dependencies and Imports: Ensure that all dependencies and imports used by the function are correctly set up and functioning as expected. This includes checking any database operations or external service calls.

  5. Recent Changes: Check if there have been any recent changes to the DocumentService or related modules that could affect the function's behavior.

Unfortunately, I couldn't find specific details about the expected inputs and outputs of this function in the available documentation, so reviewing the code directly might be necessary to understand its behavior fully.

To continue talking to Dosu, mention @dosu.

@dosubot[bot] commented on GitHub (Oct 31, 2024): <!-- Greeting --> Hey, @gakugaku! I'm here to help you with any bugs, questions, or contributions you have for the Dify project. Let me know how I can assist you! <!-- Answer --> The error you're encountering, "TypeError: cannot unpack non-iterable NoneType object," suggests that the `DocumentService.save_document_with_dataset_id` function is returning `None` instead of the expected tuple of `documents` and `batch`. This could happen if the function encounters an error or a condition where it doesn't return the expected values. Here are a few steps you can take to troubleshoot and resolve this issue: 1. **Check for Exceptions**: Ensure that the function is not encountering an exception that causes it to return `None`. Review the function's implementation to see if there are any conditions or exceptions that might lead to this behavior. 2. **Review Function Logic**: Verify the logic within `DocumentService.save_document_with_dataset_id` to ensure it correctly handles all input scenarios and returns the expected tuple. 3. **Logging**: Add logging within the function to trace its execution path and identify where it might be returning `None`. 4. **Dependencies and Imports**: Ensure that all dependencies and imports used by the function are correctly set up and functioning as expected. This includes checking any database operations or external service calls. 5. **Recent Changes**: Check if there have been any recent changes to the `DocumentService` or related modules that could affect the function's behavior. Unfortunately, I couldn't find specific details about the expected inputs and outputs of this function in the available documentation, so reviewing the code directly might be necessary to understand its behavior fully. <!-- Dosu Comment Footer --> *To continue talking to [Dosu](https://dosu.dev), mention @dosu.*
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#6465