code block result length setting wrong #5331

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

Originally created by @hanwsf on GitHub (Sep 1, 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

.env: CODE_MAX_STRING_ARRAY_LENGTH=30

✔️ Expected Behavior

Actual result from code block shall be more than 30 characters.

Actual Behavior

Node Code 4 run failed: The length of output variable result must be less than 30 characters

String length not array length.

Originally created by @hanwsf on GitHub (Sep 1, 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 .env: CODE_MAX_STRING_ARRAY_LENGTH=30 ### ✔️ Expected Behavior Actual result from code block shall be more than 30 characters. ### ❌ Actual Behavior Node Code 4 run failed: The length of output variable `result` must be less than 30 characters String length not array length.
yindo added the 🐞 bug label 2026-02-21 18:10:27 -05:00
yindo closed this issue 2026-02-21 18:10:27 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Sep 1, 2024):

The issue you're encountering is due to a misunderstanding between CODE_MAX_STRING_ARRAY_LENGTH and CODE_MAX_STRING_LENGTH. The CODE_MAX_STRING_ARRAY_LENGTH environment variable controls the maximum length of arrays of strings, not the length of individual strings within those arrays.

To allow strings longer than 30 characters, you need to set the CODE_MAX_STRING_LENGTH environment variable to a value greater than 30 in your .env file. For example:

CODE_MAX_STRING_LENGTH=80000

This will ensure that individual strings can be up to 80,000 characters long. The CODE_MAX_STRING_ARRAY_LENGTH should remain as it is if you want to limit the number of strings in an array to 30.

Make sure to update your .env file accordingly and restart your application to apply the changes [1][2][3].

To continue talking to Dosu, mention @dosu.

@dosubot[bot] commented on GitHub (Sep 1, 2024): <!-- Answer --> The issue you're encountering is due to a misunderstanding between `CODE_MAX_STRING_ARRAY_LENGTH` and `CODE_MAX_STRING_LENGTH`. The `CODE_MAX_STRING_ARRAY_LENGTH` environment variable controls the maximum length of arrays of strings, not the length of individual strings within those arrays. To allow strings longer than 30 characters, you need to set the `CODE_MAX_STRING_LENGTH` environment variable to a value greater than 30 in your `.env` file. For example: ```env CODE_MAX_STRING_LENGTH=80000 ``` This will ensure that individual strings can be up to 80,000 characters long. The `CODE_MAX_STRING_ARRAY_LENGTH` should remain as it is if you want to limit the number of strings in an array to 30. Make sure to update your `.env` file accordingly and restart your application to apply the changes <sup>[[1]](https://github.com/langgenius/dify/blob/main/api/.env.example)</sup><sup>[[2]](https://github.com/langgenius/dify/blob/main/api/configs/feature/__init__.py)</sup><sup>[[3]](https://github.com/langgenius/dify/blob/main/api/core/workflow/nodes/code/code_node.py)</sup>. <!-- Dosu Comment Footer --> *To continue talking to [Dosu](https://dosu.dev), mention @dosu.*
Author
Owner
@crazywoola commented on GitHub (Sep 1, 2024): Duplicated - https://github.com/langgenius/dify/issues/7835 - https://github.com/langgenius/dify/issues/7750 - https://github.com/langgenius/dify/issues/7688 - https://github.com/langgenius/dify/issues/7854
Author
Owner
@Sure0520 commented on GitHub (Sep 1, 2024): > 重复 > > * [输出变量的长度`result_json`必须小于 30 个字符 #7835](https://github.com/langgenius/dify/issues/7835) > * [KOD - 错误 - 长度为 30 个字符。 #7750](https://github.com/langgenius/dify/issues/7750) > * [重大变更,工作流代码节点的输出变量长度限制 #7688](https://github.com/langgenius/dify/issues/7688) > * [在“图书翻译”模板中,工作流程的“代码”链接`chunks[0]`必须少于 30 个字符 #7854](https://github.com/langgenius/dify/issues/7854) 0.7.2,My .env file is also set to 80000, but I still get an error
Author
Owner

@Bourne-alt commented on GitHub (Sep 1, 2024):

The issue you're encountering is due to a misunderstanding between CODE_MAX_STRING_ARRAY_LENGTH and CODE_MAX_STRING_LENGTH. The CODE_MAX_STRING_ARRAY_LENGTH environment variable controls the maximum length of arrays of strings, not the length of individual strings within those arrays.

To allow strings longer than 30 characters, you need to set the CODE_MAX_STRING_LENGTH environment variable to a value greater than 30 in your .env file. For example:

CODE_MAX_STRING_LENGTH=80000

This will ensure that individual strings can be up to 80,000 characters long. The CODE_MAX_STRING_ARRAY_LENGTH should remain as it is if you want to limit the number of strings in an array to 30.

Make sure to update your .env file accordingly and restart your application to apply the changes [1][2][3].

To continue talking to Dosu, mention @dosu.

@dosu Hi My .env file is also set to 80000, but I still get an error

@Bourne-alt commented on GitHub (Sep 1, 2024): > The issue you're encountering is due to a misunderstanding between `CODE_MAX_STRING_ARRAY_LENGTH` and `CODE_MAX_STRING_LENGTH`. The `CODE_MAX_STRING_ARRAY_LENGTH` environment variable controls the maximum length of arrays of strings, not the length of individual strings within those arrays. > > To allow strings longer than 30 characters, you need to set the `CODE_MAX_STRING_LENGTH` environment variable to a value greater than 30 in your `.env` file. For example: > > ```dotenv > CODE_MAX_STRING_LENGTH=80000 > ``` > > This will ensure that individual strings can be up to 80,000 characters long. The `CODE_MAX_STRING_ARRAY_LENGTH` should remain as it is if you want to limit the number of strings in an array to 30. > > Make sure to update your `.env` file accordingly and restart your application to apply the changes [[1]](https://github.com/langgenius/dify/blob/main/api/.env.example)[[2]](https://github.com/langgenius/dify/blob/main/api/configs/feature/__init__.py)[[3]](https://github.com/langgenius/dify/blob/main/api/core/workflow/nodes/code/code_node.py). > > _To continue talking to [Dosu](https://dosu.dev), mention @dosu._ @dosu Hi My .env file is also set to 80000, but I still get an error
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#5331