langgenius / dify

Dify is an open-source LLM app development platform. Dify's intuitive interface combines AI workflow, RAG pipeline, agent capabilities, model management, observability features and more, letting you quickly go from prototype to production.
https://dify.ai
Other
50.05k stars 7.15k forks source link

Cuold not delete empty knowledge #5935

Closed nhha1602 closed 3 months ago

nhha1602 commented 3 months ago

Self Checks

Dify version

0.6.12

Cloud or Self Hosted

Cloud

Steps to reproduce

I tried to delete an empty knowledge but not OK. I check the log dify-api & on the screen, and get below information:

On dify-api:

2024-07-03 10:35:41,330.330 INFO [Thread-606 (process_request_thread)] [_internal.py:97] - 127.0.0.6 - - [03/Jul/2024 10:35:41] "GET /console/api/datasets/**26b17ea7-e3ca-4bbe-98c2-a915863d11ca**/use-check HTTP/1.1" 404 - I checked on DB, the id: 26b17ea7-e3ca-4bbe-98c2-a915863d11ca still exist on datasets table.

On the screen of dify GUI:

image

There is no document in this knowledge:

image

Please help to check it.

✔️ Expected Behavior

Delete an empty knowledge successfully

❌ Actual Behavior

Cuold not delete an empty knowledge

dosubot[bot] commented 3 months ago

The issue you're encountering seems to be related to the use-check endpoint returning a 404 error, which indicates that the resource was not found. This could be due to several reasons, such as the knowledge entry not being properly indexed or an issue with the API endpoint itself.

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

  1. Verify the Knowledge Entry Exists: Ensure that the knowledge entry with the ID 26b17ea7-e3ca-4bbe-98c2-a915863d11ca exists in the datasets table. You mentioned that it still exists, so this step is confirmed.

  2. Check for Active Dependencies: Ensure that there are no active dependencies or references to this knowledge entry that might prevent its deletion. The deletion process checks for dependencies and will not proceed if any are found [1].

  3. API Endpoint Validation: Confirm that the use-check endpoint is correctly implemented and accessible. The 404 error suggests that the endpoint might not be correctly set up or the request URL might be incorrect.

  4. Frontend Error Handling: The frontend is displaying a "Failed to load resource" error and a "SyntaxError: Unexpected token '<'" error. This indicates that the response from the server is not valid JSON, possibly an HTML error page. Ensure that the API responses are correctly formatted as JSON.

  5. Logs and Error Messages: Review the logs and error messages for any additional clues. The dify-api logs indicate a 404 error, which needs to be addressed at the API level.

  6. Database Integrity: Ensure that the database schema and foreign key constraints are correctly set up to allow for the deletion of knowledge entries. The clean_dataset_task function should handle the removal of related records [2].

If these steps do not resolve the issue, it might be necessary to investigate further into the API implementation and the specific conditions checked by the use-check endpoint before allowing the deletion of a knowledge entry.

To continue talking to Dosu, mention @dosu.

crazywoola commented 3 months ago

Unfortunately I can't reproduce the issue in the Cloud version.

/console/api/datasets/**26b17ea7-e3ca-4bbe-98c2-a915863d11ca**/use-check

This one looks strange to me, because there are two '*' in front of the id and in the end of it.

nhha1602 commented 3 months ago

Unfortunately I can't reproduce the issue in the Cloud version.

/console/api/datasets/**26b17ea7-e3ca-4bbe-98c2-a915863d11ca**/use-check

This one looks strange to me, because there are two '*' in front of the id and in the end of it.

Hi, I set it as BOLD characters, so it has "**".

nhha1602 commented 3 months ago
  • Check for Active Dependencies: Ensure that there are no active dependencies or references to this knowledge entry that might prevent its deletion. The deletion process checks for dependencies and will not proceed if any are found [1].
  • API Endpoint Validation: Confirm that the use-check endpoint is correctly implemented and accessible. The 404 error suggests that the endpoint might not be correctly set up or the request URL might be incorrect.
  • Fronten

Hi,

Let me check your comments and updates.

nhha1602 commented 3 months ago

Hi,

Base on the log below in dify-api, then:

2024-07-04 01:14:19,488.488 INFO [Thread-615 (process_request_thread)] [_internal.py:97] - 127.0.0.6 - - [04/Jul/2024 01:14:19] "GET /console/api/datasets/26b17ea7-e3ca-4bbe-98c2-a915863d11ca/error-docs HTTP/1.1" 200 - 2024-07-04 01:14:19,497.497 INFO [Thread-617 (process_request_thread)] [_internal.py:97] - 127.0.0.6 - - [04/Jul/2024 01:14:19] "GET /console/api/datasets/26b17ea7-e3ca-4bbe-98c2-a915863d11ca/related-apps HTTP/1.1" 200 - 2024-07-04 01:14:19,503.503 INFO [Thread-616 (process_request_thread)] [_internal.py:97] - 127.0.0.6 - - [04/Jul/2024 01:14:19] "GET /console/api/datasets/26b17ea7-e3ca-4bbe-98c2-a915863d11ca/documents?page=1&limit=15&keyword=&fetch= HTTP/1.1" 200 - 2024-07-04 01:14:19,532.532 INFO [Thread-614 (process_request_thread)] [_internal.py:97] - 127.0.0.6 - - [04/Jul/2024 01:14:19] "GET /console/api/datasets/26b17ea7-e3ca-4bbe-98c2-a915863d11ca HTTP/1.1" 200 - 2024-07-04 01:15:24,376.376 INFO [Thread-618 (process_request_thread)] [_internal.py:97] - 127.0.0.6 - - [04/Jul/2024 01:15:24] "GET /console/api/tags?type=knowledge HTTP/1.1" 200 - 2024-07-04 01:15:24,428.428 INFO [Thread-619 (process_request_thread)] [_internal.py:97] - 127.0.0.6 - - [04/Jul/2024 01:15:24] "GET /console/api/datasets?page=1&limit=30 HTTP/1.1" 200 - 2024-07-04 01:15:26,424.424 INFO [Thread-620 (process_request_thread)] [_internal.py:97] - 127.0.0.6 - - [04/Jul/2024 01:15:26] "GET /console/api/datasets/26b17ea7-e3ca-4bbe-98c2-a915863d11ca/use-check HTTP/1.1" 404 -

nhha1602 commented 3 months ago

Hi,

I just found that, this knowledge relates to the logs of hitting test and app testing in Retrieval Testing. If that, how to delete these logs on the GUI ?

nhha1602 commented 3 months ago

I tried to create a new knowledge with following senario:

nhha1602 commented 3 months ago

Hi,

The issue is caused by there is no API: api.add_resource(DatasetUseCheckApi, '/datasets//use-check') in /api/controllers/console/datasets/datasets.py of dify-api 0.6.12.