offical website error:"tool invoke error: cannot access local variable 'retrieval_resource_list' where it is not associated with a value" #8866

Closed
opened 2026-02-21 18:28:15 -05:00 by yindo · 4 comments
Owner

Originally created by @TigerHH6866 on GitHub (Mar 2, 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

offical online website

Cloud or Self Hosted

Cloud

Steps to reproduce

create agent and chat with knowledge base

✔️ Expected Behavior

No response

Actual Behavior

请求
{"dataset_6e84519f_9bcd_42c5_82b7_6be18ee51bbe": {"query": "图书馆地址"}}
响应
{"dataset_6e84519f_9bcd_42c5_82b7_6be18ee51bbe": "tool invoke error: cannot access local variable 'retrieval_resource_list' where it is not associated with a value"}

Image
Originally created by @TigerHH6866 on GitHub (Mar 2, 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 offical online website ### Cloud or Self Hosted Cloud ### Steps to reproduce create agent and chat with knowledge base ### ✔️ Expected Behavior _No response_ ### ❌ Actual Behavior 请求 {"dataset_6e84519f_9bcd_42c5_82b7_6be18ee51bbe": {"query": "图书馆地址"}} 响应 {"dataset_6e84519f_9bcd_42c5_82b7_6be18ee51bbe": "tool invoke error: cannot access local variable 'retrieval_resource_list' where it is not associated with a value"} <img width="1680" alt="Image" src="https://github.com/user-attachments/assets/b23842fb-ce0c-455b-8604-e86cb58b63e1" />
yindo added the 🐞 bugcloud labels 2026-02-21 18:28:15 -05:00
yindo closed this issue 2026-02-21 18:28:16 -05:00
Author
Owner

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

The error message "cannot access local variable 'retrieval_resource_list' where it is not associated with a value" suggests that the retrieval_resource_list variable is being accessed before it has been properly initialized or assigned a value. In the Dify codebase, retrieval_resource_list is typically initialized as an empty list before being populated with data from external and Dify documents [1].

To address this issue, ensure that the retrieval_resource_list is initialized before any operations that attempt to access it. This initialization should occur at the beginning of the relevant function or code block, as shown in the code snippet:

retrieval_resource_list = []

This initialization should be placed before any loops or logic that populate the list with document data. If the error persists, review the code paths to ensure that there are no conditions where the variable might be accessed without being initialized.

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 2, 2025): <!-- Answer --> The error message "cannot access local variable 'retrieval_resource_list' where it is not associated with a value" suggests that the `retrieval_resource_list` variable is being accessed before it has been properly initialized or assigned a value. In the Dify codebase, `retrieval_resource_list` is typically initialized as an empty list before being populated with data from external and Dify documents <sup>[[1]](https://github.com/langgenius/dify/blob/main/api/core/rag/retrieval/dataset_retrieval.py)</sup>. To address this issue, ensure that the `retrieval_resource_list` is initialized before any operations that attempt to access it. This initialization should occur at the beginning of the relevant function or code block, as shown in the code snippet: ```python retrieval_resource_list = [] ``` This initialization should be placed before any loops or logic that populate the list with document data. If the error persists, review the code paths to ensure that there are no conditions where the variable might be accessed without being initialized. <!-- 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/ae93ae20-3bc6-42a7-ae06-75ae4cb34b17?feedback_type=great_response) | [Irrelevant Answer](https://app.dosu.dev/response-feedback/ae93ae20-3bc6-42a7-ae06-75ae4cb34b17?feedback_type=irrelevant_answer) | [Incorrect Sources](https://app.dosu.dev/response-feedback/ae93ae20-3bc6-42a7-ae06-75ae4cb34b17?feedback_type=incorrect_sources) | [Too Verbose](https://app.dosu.dev/response-feedback/ae93ae20-3bc6-42a7-ae06-75ae4cb34b17?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/ae93ae20-3bc6-42a7-ae06-75ae4cb34b17?feedback_type=hallucination) | [Bug Report](https://app.dosu.dev/response-feedback/ae93ae20-3bc6-42a7-ae06-75ae4cb34b17?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/ae93ae20-3bc6-42a7-ae06-75ae4cb34b17?feedback_type=other)</sup>
Author
Owner

@zz240 commented on GitHub (Mar 8, 2025):

We're facing this same problem in our local deployment setup, and it's the v1.0.0, Can you help us out........

@zz240 commented on GitHub (Mar 8, 2025): We're facing this same problem in our local deployment setup, and it's the v1.0.0, Can you help us out........
Author
Owner

@erigo commented on GitHub (Mar 20, 2025):

There should be something wrong with the settings of your knowledge base. First, try conducting a "retrieval test" in the knowledge base to see if the data can be retrieved correctly.

@erigo commented on GitHub (Mar 20, 2025): There should be something wrong with the settings of your knowledge base. First, try conducting a "retrieval test" in the knowledge base to see if the data can be retrieved correctly.
Author
Owner

@EcoleKeine commented on GitHub (Mar 23, 2025):

There should be something wrong with the settings of your knowledge base. First, try conducting a "retrieval test" in the knowledge base to see if the data can be retrieved correctly.

v1.1.1

same problem
I try some text, get error if retrieval test return 0 records

请求
{"dataset_5e897e28_87e2_4f3b_b985_9e28be404358": {"query": "2024年2月单件费用同环比"}}
响应
{"dataset_5e897e28_87e2_4f3b_b985_9e28be404358": "# 单件成本:……"
请求
{"dataset_5e897e28_87e2_4f3b_b985_9e28be404358": {"query": "每行代表什么"}}
响应
{"dataset_5e897e28_87e2_4f3b_b985_9e28be404358": "tool invoke error: cannot access local variable 'retrieval_resource_list' where it is not associated with a value"}
@EcoleKeine commented on GitHub (Mar 23, 2025): > There should be something wrong with the settings of your knowledge base. First, try conducting a "retrieval test" in the knowledge base to see if the data can be retrieved correctly. v1.1.1 same problem I try some text, get error if retrieval test return 0 records ``` 请求 {"dataset_5e897e28_87e2_4f3b_b985_9e28be404358": {"query": "2024年2月单件费用同环比"}} 响应 {"dataset_5e897e28_87e2_4f3b_b985_9e28be404358": "# 单件成本:……" ``` ``` 请求 {"dataset_5e897e28_87e2_4f3b_b985_9e28be404358": {"query": "每行代表什么"}} 响应 {"dataset_5e897e28_87e2_4f3b_b985_9e28be404358": "tool invoke error: cannot access local variable 'retrieval_resource_list' where it is not associated with a value"} ```
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#8866