[BUG] Code Block fails with error: The length of output variable result must be less than 80000 characters #6016

Closed
opened 2026-02-21 18:13:42 -05:00 by yindo · 5 comments
Owner

Originally created by @Emasoft on GitHub (Oct 10, 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.9.1

Cloud or Self Hosted

Cloud

Steps to reproduce

  1. Create a code block and add it to the workflow.
  2. Write any code that generates a string with more than 80000 characters.
  3. execute the code block

✔️ Expected Behavior

The code block should be able to output more than a measly 80Kb (I hope!) to the next block.

Actual Behavior

The code block task fails with the error: "The length of output variable result must be less than 80000 characters".
That doesn’t make any sense. Nothing serious that can be done with just a negligible 80Kb output. Maybe it intended 80Mb? And an error made the limit be reduced by a factor of 10? Even so, it would be too limiting.

Originally created by @Emasoft on GitHub (Oct 10, 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.9.1 ### Cloud or Self Hosted Cloud ### Steps to reproduce 1. Create a code block and add it to the workflow. 2. Write any code that generates a string with more than 80000 characters. 3. execute the code block ### ✔️ Expected Behavior The code block should be able to output more than a measly 80Kb (I hope!) to the next block. ### ❌ Actual Behavior The code block task fails with the error: "The length of output variable `result` must be less than 80000 characters". That doesn’t make any sense. Nothing serious that can be done with just a negligible 80Kb output. Maybe it intended 80Mb? And an error made the limit be reduced by a factor of 10? Even so, it would be too limiting.
yindo added the 🐞 bug label 2026-02-21 18:13:42 -05:00
yindo closed this issue 2026-02-21 18:13:42 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Oct 10, 2024):

The issue you're encountering is due to a limit set in Dify version 0.9.1, where the output variable result must be less than 80,000 characters. This is controlled by the CODE_MAX_STRING_LENGTH configuration, which is indeed set to 80,000 characters by default [1].

To resolve this, you can increase the limit by setting the CODE_MAX_STRING_LENGTH environment variable to a higher value. Here's how you can do it:

  1. Set the environment variable in your configuration or .env file:

    CODE_MAX_STRING_LENGTH=160000  # Example: setting it to 160,000 characters
    
  2. Restart your application to apply the changes.

This should allow your code block to handle larger outputs.

To continue talking to Dosu, mention @dosu.

@dosubot[bot] commented on GitHub (Oct 10, 2024): <!-- Answer --> The issue you're encountering is due to a limit set in Dify version 0.9.1, where the output variable `result` must be less than 80,000 characters. This is controlled by the `CODE_MAX_STRING_LENGTH` configuration, which is indeed set to 80,000 characters by default <sup>[[1]](https://github.com/langgenius/dify/blob/main/api/core/workflow/nodes/code/code_node.py)</sup>. To resolve this, you can increase the limit by setting the `CODE_MAX_STRING_LENGTH` environment variable to a higher value. Here's how you can do it: 1. Set the environment variable in your configuration or `.env` file: ```env CODE_MAX_STRING_LENGTH=160000 # Example: setting it to 160,000 characters ``` 2. Restart your application to apply the changes. This should allow your code block to handle larger outputs. <!-- Dosu Comment Footer --> *To continue talking to [Dosu](https://dosu.dev), mention @dosu.*
Author
Owner

@Emasoft commented on GitHub (Oct 10, 2024):

Then you should open a Feature Request to make the value CODE_MAX_STRING_LENGTH customizable at runtime for each workflow. You can’t force the user to restart the application anytime. Not to mention the Cloud version of Dify that cannot be restarted by the users. Different workflows have different needs. This limit must be set by the user according to what kind of data he processes.

@Emasoft commented on GitHub (Oct 10, 2024): Then you should open a Feature Request to make the value CODE_MAX_STRING_LENGTH customizable at runtime for each workflow. You can’t force the user to restart the application anytime. Not to mention the Cloud version of Dify that cannot be restarted by the users. Different workflows have different needs. This limit must be set by the user according to what kind of data he processes.
Author
Owner

@crazywoola commented on GitHub (Oct 10, 2024):

We do not plan to adjust this value in our cloud version.

@crazywoola commented on GitHub (Oct 10, 2024): We do not plan to adjust this value in our cloud version.
Author
Owner

@mcwongaagpt commented on GitHub (Apr 24, 2025):

I use docker compose down
After change .env,
docker compose -f docker-compose.yaml up -d

The issue is still occur
What is the reason

@mcwongaagpt commented on GitHub (Apr 24, 2025): I use docker compose down After change .env, docker compose -f docker-compose.yaml up -d The issue is still occur What is the reason
Author
Owner

@fernvenue commented on GitHub (May 21, 2025):

I think that will be great if it can be no limit when we set it to 0.

@fernvenue commented on GitHub (May 21, 2025): I think that will be great if it can be no limit when we set it to `0`.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#6016