knowledge base api when delete metadata by openapi, got 500 server error #11885

Closed
opened 2026-02-21 19:04:34 -05:00 by yindo · 1 comment
Owner

Originally created by @StrayDragon on GitHub (Mar 20, 2025).

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

1.1.1

Cloud or Self Hosted

Cloud, Self Hosted (Source)

Steps to reproduce

  1. create a test metadata, and save result 'id' field assume: 'XXX'
curl --location --request POST 'http://ai.urchinet.lan/v1/datasets/{dataset_id}/metadata' \
--header 'Authorization: Bearer {api_key}' \
--header 'Content-Type: application/json'\
--data-raw '{"type": "string", "name": "test"}'
  1. try delete last step created metadata 'XXX'
curl --location --request DELETE 'http://ai.urchinet.lan/v1/datasets/{dataset_id}/metadata/XXX' \
--header 'Authorization: Bearer {api_key}'

you will got result 500

and running dev server exception trackback here

backend-api    | Traceback (most recent call last):
backend-api    |   File "-/dify/api/.venv/lib/python3.12/site-packages/flask/app.py", line 917, in full_dispatch_request
w Enable Watch
backend-api    |          ^^^^^^^^^^^^^^^^^^^^^^^
backend-api    |   File "-/dify/api/.venv/lib/python3.12/site-packages/flask/app.py", line 902, in dispatch_request
backend-api    |     return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]
backend-api    |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
backend-api    |   File "-/dify/api/.venv/lib/python3.12/site-packages/flask_restful/__init__.py", line 489, in wrapper
backend-api    |     resp = resource(*args, **kwargs)
backend-api    |            ^^^^^^^^^^^^^^^^^^^^^^^^^
backend-api    |   File "-/dify/api/.venv/lib/python3.12/site-packages/flask/views.py", line 110, in view
backend-api    |     return current_app.ensure_sync(self.dispatch_request)(**kwargs)  # type: ignore[no-any-return]
backend-api    |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
backend-api    |   File "-/dify/api/.venv/lib/python3.12/site-packages/flask_restful/__init__.py", line 604, in dispatch_request
backend-api    |     resp = meth(*args, **kwargs)
backend-api    |            ^^^^^^^^^^^^^^^^^^^^^
backend-api    |   File "-/dify/api/controllers/service_api/wraps.py", line 207, in decorated
backend-api    |     return view(api_token.tenant_id, *args, **kwargs)
backend-api    |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
backend-api    | TypeError: DatasetMetadataServiceApi.delete() got multiple values for argument 'dataset_id'

ref knowledge(dataset) openapi doc: https://cloud.dify.ai/datasets?category=api

✔️ Expected Behavior

200 OK

Actual Behavior

500 Internal Error

Originally created by @StrayDragon on GitHub (Mar 20, 2025). ### 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 1.1.1 ### Cloud or Self Hosted Cloud, Self Hosted (Source) ### Steps to reproduce 1. create a test metadata, and save result 'id' field assume: 'XXX' ```bash curl --location --request POST 'http://ai.urchinet.lan/v1/datasets/{dataset_id}/metadata' \ --header 'Authorization: Bearer {api_key}' \ --header 'Content-Type: application/json'\ --data-raw '{"type": "string", "name": "test"}' ``` 2. try delete last step created metadata 'XXX' ```bash curl --location --request DELETE 'http://ai.urchinet.lan/v1/datasets/{dataset_id}/metadata/XXX' \ --header 'Authorization: Bearer {api_key}' ``` you will got result 500 and running dev server exception trackback here ```bash backend-api | Traceback (most recent call last): backend-api | File "-/dify/api/.venv/lib/python3.12/site-packages/flask/app.py", line 917, in full_dispatch_request w Enable Watch backend-api | ^^^^^^^^^^^^^^^^^^^^^^^ backend-api | File "-/dify/api/.venv/lib/python3.12/site-packages/flask/app.py", line 902, in dispatch_request backend-api | return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args) # type: ignore[no-any-return] backend-api | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ backend-api | File "-/dify/api/.venv/lib/python3.12/site-packages/flask_restful/__init__.py", line 489, in wrapper backend-api | resp = resource(*args, **kwargs) backend-api | ^^^^^^^^^^^^^^^^^^^^^^^^^ backend-api | File "-/dify/api/.venv/lib/python3.12/site-packages/flask/views.py", line 110, in view backend-api | return current_app.ensure_sync(self.dispatch_request)(**kwargs) # type: ignore[no-any-return] backend-api | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ backend-api | File "-/dify/api/.venv/lib/python3.12/site-packages/flask_restful/__init__.py", line 604, in dispatch_request backend-api | resp = meth(*args, **kwargs) backend-api | ^^^^^^^^^^^^^^^^^^^^^ backend-api | File "-/dify/api/controllers/service_api/wraps.py", line 207, in decorated backend-api | return view(api_token.tenant_id, *args, **kwargs) backend-api | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ backend-api | TypeError: DatasetMetadataServiceApi.delete() got multiple values for argument 'dataset_id' ``` ref knowledge(dataset) openapi doc: https://cloud.dify.ai/datasets?category=api ### ✔️ Expected Behavior 200 OK ### ❌ Actual Behavior 500 Internal Error
yindo added the 🐞 bug label 2026-02-21 19:04:34 -05:00
yindo closed this issue 2026-02-21 19:04:34 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Mar 20, 2025):

The error message "DatasetMetadataServiceApi.delete() got multiple values for argument 'dataset_id'" suggests that there might be a conflict in how the dataset_id is being passed to the delete() method. This can occur if the routing configuration or the method signature is not correctly set up to handle the arguments.

Here are a few things to check and consider:

  1. Routing Configuration: Ensure that the Flask-RESTful routing is correctly set up to pass the dataset_id and metadata_id as separate arguments. The route should look something like this:

    api.add_resource(DatasetMetadataServiceApi, "/datasets/<uuid:dataset_id>/metadata/<uuid:metadata_id>")
    

    This ensures that both dataset_id and metadata_id are passed correctly to the delete() method.

  2. Method Signature: Verify that the delete() method in DatasetMetadataServiceApi is defined to accept both dataset_id and metadata_id as arguments. It should look like this:

    def delete(self, dataset_id, metadata_id):
        # method implementation
    
  3. UUID Conversion: Ensure that both dataset_id and metadata_id are being correctly converted to strings if necessary, as the method might expect them in a specific format.

By checking these configurations, you should be able to resolve the issue with the delete() method receiving multiple values for dataset_id. If the problem persists, reviewing the traceback and ensuring that the API endpoint is correctly defined in the OpenAPI documentation might also help.

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Bug Report | Other

@dosubot[bot] commented on GitHub (Mar 20, 2025): <!-- Answer --> The error message "DatasetMetadataServiceApi.delete() got multiple values for argument 'dataset_id'" suggests that there might be a conflict in how the `dataset_id` is being passed to the `delete()` method. This can occur if the routing configuration or the method signature is not correctly set up to handle the arguments. Here are a few things to check and consider: 1. **Routing Configuration**: Ensure that the Flask-RESTful routing is correctly set up to pass the `dataset_id` and `metadata_id` as separate arguments. The route should look something like this: ```python api.add_resource(DatasetMetadataServiceApi, "/datasets/<uuid:dataset_id>/metadata/<uuid:metadata_id>") ``` This ensures that both `dataset_id` and `metadata_id` are passed correctly to the `delete()` method. 2. **Method Signature**: Verify that the `delete()` method in `DatasetMetadataServiceApi` is defined to accept both `dataset_id` and `metadata_id` as arguments. It should look like this: ```python def delete(self, dataset_id, metadata_id): # method implementation ``` 3. **UUID Conversion**: Ensure that both `dataset_id` and `metadata_id` are being correctly converted to strings if necessary, as the method might expect them in a specific format. By checking these configurations, you should be able to resolve the issue with the `delete()` method receiving multiple values for `dataset_id`. If the problem persists, reviewing the traceback and ensuring that the API endpoint is correctly defined in the OpenAPI documentation might also help. <!-- Dosu Comment Footer --> *To continue talking to [Dosu](https://dosu.dev), mention @dosu.* --- <sup>Help Dosu learn! Give it feedback: [Great Response](https://app.dosu.dev/response-feedback/c4f04fa2-6693-4f76-be0f-7db4f5d6a68f?feedback_type=great_response) | [Irrelevant Answer](https://app.dosu.dev/response-feedback/c4f04fa2-6693-4f76-be0f-7db4f5d6a68f?feedback_type=irrelevant_answer) | [Incorrect Sources](https://app.dosu.dev/response-feedback/c4f04fa2-6693-4f76-be0f-7db4f5d6a68f?feedback_type=incorrect_sources) | [Too Verbose](https://app.dosu.dev/response-feedback/c4f04fa2-6693-4f76-be0f-7db4f5d6a68f?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/c4f04fa2-6693-4f76-be0f-7db4f5d6a68f?feedback_type=hallucination) | [Bug Report](https://app.dosu.dev/response-feedback/c4f04fa2-6693-4f76-be0f-7db4f5d6a68f?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/c4f04fa2-6693-4f76-be0f-7db4f5d6a68f?feedback_type=other)</sup>
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#11885