In the "Book Translation" template, the "Code" link of the workflow, chunks[0] must be less than 30 characters #5324

Closed
opened 2026-02-21 18:10:25 -05:00 by yindo · 2 comments
Owner

Originally created by @mipf2009 on GitHub (Aug 31, 2024).

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

0.7.2

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

52cc7cea1a7f276edce51e8edc82f06

✔️ Expected Behavior

No response

Actual Behavior

The "chunks" variable limit does not allow more than 30 characters。

Originally created by @mipf2009 on GitHub (Aug 31, 2024). ### 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 0.7.2 ### Cloud or Self Hosted Self Hosted (Docker) ### Steps to reproduce ![52cc7cea1a7f276edce51e8edc82f06](https://github.com/user-attachments/assets/84e70159-a320-47df-ab5d-de396c166dd6) ### ✔️ Expected Behavior _No response_ ### ❌ Actual Behavior The "chunks" variable limit does not allow more than 30 characters。
yindo added the 🐞 bug label 2026-02-21 18:10:25 -05:00
yindo closed this issue 2026-02-21 18:10:25 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Aug 31, 2024):

@mipf2009 Hello! I'm a bot here to help you with bugs, questions, and becoming a contributor. Let's tackle this issue together.

To resolve the error in the "Book Translation" template where the chunks[0] variable must be less than 30 characters, you can use Jinja2's string slicing feature to limit the length of the variable. Here is an example of how you can modify the template to ensure that chunks[0] is less than 30 characters:

{% raw %}
{% for item in chunks %}
### Chunk {{ loop.index }}. 
### Similarity: {{ item.metadata.score | default('N/A') }}

#### {{ item.title[:30] }}

##### Content
{{ item.content | replace('\n', '\n\n') }}

---
{% endfor %}
{% endraw %}

In this example, {{ item.title[:30] }} ensures that only the first 30 characters of item.title are used, thus preventing the error [1].

To continue talking to Dosu, mention @dosu.

@dosubot[bot] commented on GitHub (Aug 31, 2024): <!-- Greeting --> @mipf2009 Hello! I'm a bot here to help you with bugs, questions, and becoming a contributor. Let's tackle this issue together. <!-- Answer --> To resolve the error in the "Book Translation" template where the `chunks[0]` variable must be less than 30 characters, you can use Jinja2's string slicing feature to limit the length of the variable. Here is an example of how you can modify the template to ensure that `chunks[0]` is less than 30 characters: ```jinja {% raw %} {% for item in chunks %} ### Chunk {{ loop.index }}. ### Similarity: {{ item.metadata.score | default('N/A') }} #### {{ item.title[:30] }} ##### Content {{ item.content | replace('\n', '\n\n') }} --- {% endfor %} {% endraw %} ``` In this example, `{{ item.title[:30] }}` ensures that only the first 30 characters of `item.title` are used, thus preventing the error <sup>[[1]](https://github.com/langgenius/dify-docs/blob/main/zh_CN/guides/workflow/node/template.md)</sup>. <!-- Dosu Comment Footer --> *To continue talking to [Dosu](https://dosu.dev), mention @dosu.*
Author
Owner
@crazywoola commented on GitHub (Aug 31, 2024): Duplicated - https://github.com/langgenius/dify/issues/7835 - https://github.com/langgenius/dify/issues/7750 - https://github.com/langgenius/dify/issues/7688
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#5324