'list' object has no attribute 'find' #20912

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

Originally created by @fatelei on GitHub (Dec 9, 2025).

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

1.10.0

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

call api (http://cloud.dify.ai/console/api/instruction-generate)

✔️ Expected Behavior

no error

Actual Behavior

error occur

Originally created by @fatelei on GitHub (Dec 9, 2025). ### 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 1.10.0 ### Cloud or Self Hosted Self Hosted (Docker) ### Steps to reproduce call api (http://cloud.dify.ai/console/api/instruction-generate) ### ✔️ Expected Behavior no error ### ❌ Actual Behavior error occur
yindo added the 🐞 bug label 2026-02-21 20:09:46 -05:00
yindo closed this issue 2026-02-21 20:09:46 -05:00
Author
Owner

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

The error happens because the backend expects the LLM model response to be a string, but sometimes it receives a list instead. In the code, it tries to call .find on the response, which fails if the response is a list rather than a string. This occurs in the instruction generation logic, specifically in the LLMGenerator's __instruction_modify_common method, which is used by both instruction_modify_legacy and instruction_modify_workflow. If the model or a custom prompt causes the LLM to return a list (for example, a JSON array), this triggers the error when the backend tries to parse it as a string and search for braces with .find"api/core/llm_generator/llm_generator.py".

To work around this, ensure your model and prompts are configured to always return a string (ideally a JSON object as a string, not a raw list/array). If you are customizing prompts or using a non-default model, check that the output format matches what the backend expects. As a code fix, adding a type check before calling .find and converting lists to strings (e.g., using json.dumps) would prevent this error.

No recent updates or merged pull requests directly address this bug, so a code or prompt adjustment is needed to avoid the type mismatch.

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 9, 2025): <!-- Answer --> The error happens because the backend expects the LLM model response to be a string, but sometimes it receives a list instead. In the code, it tries to call .find on the response, which fails if the response is a list rather than a string. This occurs in the instruction generation logic, specifically in the LLMGenerator's __instruction_modify_common method, which is used by both instruction_modify_legacy and instruction_modify_workflow. If the model or a custom prompt causes the LLM to return a list (for example, a JSON array), this triggers the error when the backend tries to parse it as a string and search for braces with .find["api/core/llm_generator/llm_generator.py"](https://github.com/langgenius/dify/blob/51330c0ee631de49f6cc5f7b7436c00cab62d38f/api/core/llm_generator/llm_generator.py#L49-L570). To work around this, ensure your model and prompts are configured to always return a string (ideally a JSON object as a string, not a raw list/array). If you are customizing prompts or using a non-default model, check that the output format matches what the backend expects. As a code fix, adding a type check before calling .find and converting lists to strings (e.g., using json.dumps) would prevent this error. No recent updates or merged pull requests directly address this bug, so a code or prompt adjustment is needed to avoid the type mismatch. <!-- 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/e03550a3-a39e-421e-92c3-0cc96a6f54c0?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/e03550a3-a39e-421e-92c3-0cc96a6f54c0?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/e03550a3-a39e-421e-92c3-0cc96a6f54c0?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/e03550a3-a39e-421e-92c3-0cc96a6f54c0?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/e03550a3-a39e-421e-92c3-0cc96a6f54c0?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/e03550a3-a39e-421e-92c3-0cc96a6f54c0?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/e03550a3-a39e-421e-92c3-0cc96a6f54c0?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%20error%20happens%20because%20the%20backend%20expects%20the%20LLM%20model%20response%20to%20be%20a%20string%2C%20but%20sometimes%20it%20receives%20a%20list%20instead.%20In%20the%20code%2C%20it%20tries%20to%20call%20.find%20on%20the%20response%2C%20which%20fails%20if%20the%20response%20is%20a%20list%20rather%20than%20a%20string.%20This%20occurs%20in%20the%20instruction%20generation%20logic%2C%20specifically%20in%20the%20LLMGenerator%27s%20__instruction_modify_common%20method%2C%20which%20is%20used%20by%20both%20instruction_modify_legacy%20and%20instruction_modify_workflow.%20If%20the%20model%20or%20a%20custom%20prompt%20causes%20the%20LLM%20to%20return%20a%20list%20%28for%20example%2C%20a%20JSON%20array%29%2C%20this%20triggers%20the%20error%20when%20the%20backend%20tries%20to%20parse%20it%20as%20a%20string%20and%20search%20for%20braces%20with%20.find%5B%22api/core/llm_generator/llm_generator.py%22%5D%28https%3A//github.com/langgenius/dify/blob/51330c0ee631de49f6cc5f7b7436c00cab62d38f/api/core/llm_generator/llm_generator.py%23L49-L570%29.%0A%0ATo%20work%20around%20this%2C%20ensure%20your%20model%20and%20prompts%20are%20configured%20to%20always%20return%20a%20string%20%28ideally%20a%20JSON%20object%20as%20a%20string%2C%20not%20a%20raw%20list/array%29.%20If%20you%20are%20customizing%20prompts%20or%20using%20a%20non-default%20model%2C%20check%20that%20the%20output%20format%20matches%20what%20the%20backend%20expects.%20As%20a%20code%20fix%2C%20adding%20a%20type%20check%20before%20calling%20.find%20and%20converting%20lists%20to%20strings%20%28e.g.%2C%20using%20json.dumps%29%20would%20prevent%20this%20error.%0A%0ANo%20recent%20updates%20or%20merged%20pull%20requests%20directly%20address%20this%20bug%2C%20so%20a%20code%20or%20prompt%20adjustment%20is%20needed%20to%20avoid%20the%20type%20mismatch.)&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/29383)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#20912