The request parameters retrieve the attachment_ids field, but this field does not exist in the actual request data. #20989

Closed
opened 2026-02-21 20:10:08 -05:00 by yindo · 1 comment
Owner

Originally created by @Ykubernetes on GitHub (Dec 11, 2025).

Originally assigned to: @JohnJyong on GitHub.

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

v1.11.0

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

api-1 | 2025-12-12 11:12:15.993 ERROR [Dummy-4] [app.py:875] - Exception on /console/api/datasets/7d76416d-1695-4ba3-a10b-90d8a5060584/external-hit-testing [POST]
api-1 | Traceback (most recent call last):
api-1 | File "/app/api/.venv/lib/python3.12/site-packages/flask/app.py", line 917, in full_dispatch_request
api-1 | rv = self.dispatch_request()
api-1 | ^^^^^^^^^^^^^^^^^^^^^^^
api-1 | File "/app/api/.venv/lib/python3.12/site-packages/flask/app.py", line 902, in dispatch_request
api-1 | return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args) # type: ignore[no-any-return]
api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
api-1 | File "/app/api/.venv/lib/python3.12/site-packages/flask_restx/api.py", line 404, in wrapper
api-1 | resp = resource(*args, **kwargs)
api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^
api-1 | File "/app/api/.venv/lib/python3.12/site-packages/flask/views.py", line 110, in view
api-1 | return current_app.ensure_sync(self.dispatch_request)(**kwargs) # type: ignore[no-any-return]
api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
api-1 | File "/app/api/.venv/lib/python3.12/site-packages/flask_restx/resource.py", line 41, in dispatch_request
api-1 | resp = meth(*args, **kwargs)
api-1 | ^^^^^^^^^^^^^^^^^^^^^
api-1 | File "/app/api/controllers/console/wraps.py", line 220, in decorated
api-1 | return view(*args, **kwargs)
api-1 | ^^^^^^^^^^^^^^^^^^^^^
api-1 | File "/app/api/libs/login.py", line 80, in decorated_view
api-1 | return current_app.ensure_sync(func)(*args, **kwargs)
api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
api-1 | File "/app/api/controllers/console/wraps.py", line 37, in decorated
api-1 | return view(*args, **kwargs)
api-1 | ^^^^^^^^^^^^^^^^^^^^^
api-1 | File "/app/api/controllers/console/datasets/external.py", line 296, in post
api-1 | HitTestingService.hit_testing_args_check(payload.model_dump())
api-1 | File "/app/api/services/hit_testing_service.py", line 182, in hit_testing_args_check
api-1 | attachment_ids = args["attachment_ids"]
api-1 | ~~~~^^^^^^^^^^^^^^^^^^
api-1 | KeyError: 'attachment_ids'

✔️ Expected Behavior

This issue occurred when using the dify link to the ragflow knowledge base.

Actual Behavior

No response

Originally created by @Ykubernetes on GitHub (Dec 11, 2025). Originally assigned to: @JohnJyong on GitHub. ### 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 v1.11.0 ### Cloud or Self Hosted Self Hosted (Docker) ### Steps to reproduce api-1 | 2025-12-12 11:12:15.993 ERROR [Dummy-4] [app.py:875] - Exception on /console/api/datasets/7d76416d-1695-4ba3-a10b-90d8a5060584/external-hit-testing [POST] api-1 | Traceback (most recent call last): api-1 | File "/app/api/.venv/lib/python3.12/site-packages/flask/app.py", line 917, in full_dispatch_request api-1 | rv = self.dispatch_request() api-1 | ^^^^^^^^^^^^^^^^^^^^^^^ api-1 | File "/app/api/.venv/lib/python3.12/site-packages/flask/app.py", line 902, in dispatch_request api-1 | return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args) # type: ignore[no-any-return] api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ api-1 | File "/app/api/.venv/lib/python3.12/site-packages/flask_restx/api.py", line 404, in wrapper api-1 | resp = resource(*args, **kwargs) api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^ api-1 | File "/app/api/.venv/lib/python3.12/site-packages/flask/views.py", line 110, in view api-1 | return current_app.ensure_sync(self.dispatch_request)(**kwargs) # type: ignore[no-any-return] api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ api-1 | File "/app/api/.venv/lib/python3.12/site-packages/flask_restx/resource.py", line 41, in dispatch_request api-1 | resp = meth(*args, **kwargs) api-1 | ^^^^^^^^^^^^^^^^^^^^^ api-1 | File "/app/api/controllers/console/wraps.py", line 220, in decorated api-1 | return view(*args, **kwargs) api-1 | ^^^^^^^^^^^^^^^^^^^^^ api-1 | File "/app/api/libs/login.py", line 80, in decorated_view api-1 | return current_app.ensure_sync(func)(*args, **kwargs) api-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ api-1 | File "/app/api/controllers/console/wraps.py", line 37, in decorated api-1 | return view(*args, **kwargs) api-1 | ^^^^^^^^^^^^^^^^^^^^^ api-1 | File "/app/api/controllers/console/datasets/external.py", line 296, in post api-1 | HitTestingService.hit_testing_args_check(payload.model_dump()) api-1 | File "/app/api/services/hit_testing_service.py", line 182, in hit_testing_args_check api-1 | attachment_ids = args["attachment_ids"] api-1 | ~~~~^^^^^^^^^^^^^^^^^^ api-1 | KeyError: 'attachment_ids' ### ✔️ Expected Behavior This issue occurred when using the dify link to the ragflow knowledge base. ### ❌ Actual Behavior _No response_
yindo added the 🐞 bug label 2026-02-21 20:10:08 -05:00
yindo closed this issue 2026-02-21 20:10:08 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Dec 11, 2025):

The KeyError for 'attachment_ids' happens because, starting with Dify v1.11.0, the /console/api/datasets/<dataset_id>/external-hit-testing endpoint expects the POST payload to include an attachment_ids field—even if it's just an empty list. This requirement was added for multimodal support. If your request payload doesn't include this field, the backend will throw a KeyError when it tries to access it.

To fix this, make sure your request payload looks like this:

{
  "query": "your search query",
  "attachment_ids": [],
  "external_retrieval_model": { /* optional */ },
  "metadata_filtering_conditions": { /* optional */ }
}

If you can't update your client immediately, a temporary workaround is to change the backend code in hit_testing_service.py to use args.get('attachment_ids', []) instead of args['attachment_ids'] to avoid the error, but the recommended fix is to always include the field in your requests. More details and discussion can be found here and in the related pull request.

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other

Chat with Dosu Open in Cursor Join Discord Share on X

@dosubot[bot] commented on GitHub (Dec 11, 2025): <!-- Answer --> The KeyError for 'attachment_ids' happens because, starting with Dify v1.11.0, the `/console/api/datasets/<dataset_id>/external-hit-testing` endpoint expects the POST payload to include an `attachment_ids` field—even if it's just an empty list. This requirement was added for multimodal support. If your request payload doesn't include this field, the backend will throw a KeyError when it tries to access it. To fix this, make sure your request payload looks like this: ```json { "query": "your search query", "attachment_ids": [], "external_retrieval_model": { /* optional */ }, "metadata_filtering_conditions": { /* optional */ } } ``` If you can't update your client immediately, a temporary workaround is to change the backend code in `hit_testing_service.py` to use `args.get('attachment_ids', [])` instead of `args['attachment_ids']` to avoid the error, but the recommended fix is to always include the field in your requests. More details and discussion can be found [here](https://github.com/langgenius/dify/issues/29451) and in the related [pull request](https://github.com/langgenius/dify/pull/29115). <!-- 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/b6f96144-cec6-4f65-9900-a7a8310f1b73?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/b6f96144-cec6-4f65-9900-a7a8310f1b73?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/b6f96144-cec6-4f65-9900-a7a8310f1b73?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/b6f96144-cec6-4f65-9900-a7a8310f1b73?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/b6f96144-cec6-4f65-9900-a7a8310f1b73?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/b6f96144-cec6-4f65-9900-a7a8310f1b73?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/b6f96144-cec6-4f65-9900-a7a8310f1b73?feedback_type=other)</sup> [![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/6088a4f4-073a-43f3-b3d4-4f06fb0c05a0/ask?utm_source=github)&nbsp;[![Open in Cursor](https://dosu.dev/dosu-in-cursor.svg)](https://cursor.com/link/prompt?text=The%20KeyError%20for%20%27attachment_ids%27%20happens%20because%2C%20starting%20with%20Dify%20v1.11.0%2C%20the%20%60/console/api/datasets/%3Cdataset_id%3E/external-hit-testing%60%20endpoint%20expects%20the%20POST%20payload%20to%20include%20an%20%60attachment_ids%60%20field%E2%80%94even%20if%20it%27s%20just%20an%20empty%20list.%20This%20requirement%20was%20added%20for%20multimodal%20support.%20If%20your%20request%20payload%20doesn%27t%20include%20this%20field%2C%20the%20backend%20will%20throw%20a%20KeyError%20when%20it%20tries%20to%20access%20it.%0A%0ATo%20fix%20this%2C%20make%20sure%20your%20request%20payload%20looks%20like%20this%3A%0A%0A%60%60%60json%0A%7B%0A%20%20%22query%22%3A%20%22your%20search%20query%22%2C%0A%20%20%22attachment_ids%22%3A%20%5B%5D%2C%0A%20%20%22external_retrieval_model%22%3A%20%7B%20/%2A%20optional%20%2A/%20%7D%2C%0A%20%20%22metadata_filtering_conditions%22%3A%20%7B%20/%2A%20optional%20%2A/%20%7D%0A%7D%0A%60%60%60%0A%0AIf%20you%20can%27t%20update%20your%20client%20immediately%2C%20a%20temporary%20workaround%20is%20to%20change%20the%20backend%20code%20in%20%60hit_testing_service.py%60%20to%20use%20%60args.get%28%27attachment_ids%27%2C%20%5B%5D%29%60%20instead%20of%20%60args%5B%27attachment_ids%27%5D%60%20to%20avoid%20the%20error%2C%20but%20the%20recommended%20fix%20is%20to%20always%20include%20the%20field%20in%20your%20requests.%20More%20details%20and%20discussion%20can%20be%20found%20%5Bhere%5D%28https%3A//github.com/langgenius/dify/issues/29451%29%20and%20in%20the%20related%20%5Bpull%20request%5D%28https%3A//github.com/langgenius/dify/pull/29115%29.)&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/29547)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#20989