langgenius / dify

Dify is an open-source LLM app development platform. Dify's intuitive interface combines AI workflow, RAG pipeline, agent capabilities, model management, observability features and more, letting you quickly go from prototype to production.
https://dify.ai
Other
47.61k stars 6.78k forks source link

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

Closed Emasoft closed 44 minutes ago

Emasoft commented 3 hours ago

Self Checks

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.

dosubot[bot] commented 3 hours ago

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.

Emasoft commented 3 hours ago

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.

crazywoola commented 44 minutes ago

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