KOD - error - 30 characters long. #5273

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

Originally created by @polhel on GitHub (Aug 28, 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

I have code to retrieve URLs from Google search. everything worked fine until I upgraded to the latest version. Now the result of the array cannot be more than 30 characters long. URLs even have 100 characters each, why this restriction?
"I have code to retrieve URLs from Google search. everything worked fine until I upgraded to the latest version. Now the result of the array cannot be more than 30 characters long. URLs even have 100 characters each, why this restriction? "

✔️ Expected Behavior

dify1

Actual Behavior

No response

Originally created by @polhel on GitHub (Aug 28, 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 I have code to retrieve URLs from Google search. everything worked fine until I upgraded to the latest version. Now the result of the array cannot be more than 30 characters long. URLs even have 100 characters each, why this restriction? "I have code to retrieve URLs from Google search. everything worked fine until I upgraded to the latest version. Now the result of the array cannot be more than 30 characters long. URLs even have 100 characters each, why this restriction? " ### ✔️ Expected Behavior ![dify1](https://github.com/user-attachments/assets/e72573c8-d5e1-496f-b8d8-3b6122572c84) ### ❌ Actual Behavior _No response_
yindo added the 🐞 bug label 2026-02-21 18:10:13 -05:00
yindo closed this issue 2026-02-21 18:10:13 -05:00
Author
Owner

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

@polhel Hello! I'm here to assist you with any bugs, questions, or contributions. Let's work together to resolve the issue you're facing.

The issue you're encountering is due to a recent change in Dify version 0.7.2, which introduced a check to ensure that the length of output variables does not exceed a certain limit. Specifically, the _check_string method now includes a check to ensure that the length of output variables does not exceed dify_config.CODE_MAX_STRING_LENGTH characters. This change is likely causing the error you're seeing, where the length of the output variable result[0] must be less than 30 characters [1].

To resolve this issue, you can either:

  1. Adjust the Configuration: Increase the value of dify_config.CODE_MAX_STRING_LENGTH to accommodate longer URLs.
  2. Modify Your Code: Ensure that the output strings are within the allowed length, possibly by truncating or splitting the URLs.

Here's the relevant code snippet for reference:

def _check_string(self, value: str, variable: str) -> str:
    if not isinstance(value, str):
        if isinstance(value, type(None)):
            return None
        else:
            raise ValueError(f"Output variable `{variable}` must be a string")
    
    if len(value) > dify_config.CODE_MAX_STRING_LENGTH:
        raise ValueError(f'The length of output variable `{variable}` must be'
                         f' less than {dify_config.CODE_MAX_STRING_LENGTH} characters')

    return value.replace('\x00', '')

You may need to adjust the dify_config.CODE_MAX_STRING_LENGTH parameter to a higher value to resolve this issue [1].

To continue talking to Dosu, mention @dosu.

@dosubot[bot] commented on GitHub (Aug 28, 2024): <!-- Greeting --> @polhel Hello! I'm here to assist you with any bugs, questions, or contributions. Let's work together to resolve the issue you're facing. <!-- Answer --> The issue you're encountering is due to a recent change in Dify version 0.7.2, which introduced a check to ensure that the length of output variables does not exceed a certain limit. Specifically, the `_check_string` method now includes a check to ensure that the length of output variables does not exceed `dify_config.CODE_MAX_STRING_LENGTH` characters. This change is likely causing the error you're seeing, where the length of the output variable `result[0]` must be less than 30 characters <sup>[[1]](https://github.com/langgenius/dify/blob/main/api/core/workflow/nodes/code/code_node.py)</sup>. To resolve this issue, you can either: 1. **Adjust the Configuration**: Increase the value of `dify_config.CODE_MAX_STRING_LENGTH` to accommodate longer URLs. 2. **Modify Your Code**: Ensure that the output strings are within the allowed length, possibly by truncating or splitting the URLs. Here's the relevant code snippet for reference: ```python def _check_string(self, value: str, variable: str) -> str: if not isinstance(value, str): if isinstance(value, type(None)): return None else: raise ValueError(f"Output variable `{variable}` must be a string") if len(value) > dify_config.CODE_MAX_STRING_LENGTH: raise ValueError(f'The length of output variable `{variable}` must be' f' less than {dify_config.CODE_MAX_STRING_LENGTH} characters') return value.replace('\x00', '') ``` You may need to adjust the `dify_config.CODE_MAX_STRING_LENGTH` parameter to a higher value to resolve this issue <sup>[[1]](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

@polhel commented on GitHub (Aug 28, 2024):

Where is "dify_config.CODE_MAX_STRING_LENGTH" ? Or in which file?

@polhel commented on GitHub (Aug 28, 2024): Where is "dify_config.CODE_MAX_STRING_LENGTH" ? Or in which file?
Author
Owner

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

The dify_config.CODE_MAX_STRING_LENGTH is defined in the api/configs/feature/__init__.py file of the Dify project. You can find it with the following line:

CODE_MAX_STRING_LENGTH: PositiveInt = Field(
    description="max string length for code execution",
    default=80000,
)

To locate the exact definition, you should look in the api/configs/feature/__init__.py file [1].

To continue talking to Dosu, mention @dosu.

@dosubot[bot] commented on GitHub (Aug 28, 2024): <!-- Answer --> The `dify_config.CODE_MAX_STRING_LENGTH` is defined in the `api/configs/feature/__init__.py` file of the Dify project. You can find it with the following line: ```python CODE_MAX_STRING_LENGTH: PositiveInt = Field( description="max string length for code execution", default=80000, ) ``` To locate the exact definition, you should look in the `api/configs/feature/__init__.py` file <sup>[[1]](https://github.com/langgenius/dify/blob/main/api/configs/feature/__init__.py)</sup>. <!-- Dosu Comment Footer --> *To continue talking to [Dosu](https://dosu.dev), mention @dosu.*
Author
Owner

@crazywoola commented on GitHub (Aug 28, 2024):

Duplicated, we already fixed this yesterday in this PR https://github.com/langgenius/dify/pull/7683

In the meantime you could downgrade to v0.7.1. We will release this fix in v0.7.3

You can define this variable in docker/.env

@crazywoola commented on GitHub (Aug 28, 2024): Duplicated, we already fixed this yesterday in this PR https://github.com/langgenius/dify/pull/7683 In the meantime you could downgrade to v0.7.1. We will release this fix in v0.7.3 You can define this variable in docker/.env
Author
Owner

@leoncool23 commented on GitHub (Aug 28, 2024):

重复,我们昨天已在此 PR #7683中修复了此问题

与此同时,你可以降级到 v0.7.1。我们将在 v0.7.3 中发布此修复程序

您可以在 docker/.env 中定义此变量

我是上午刚部署的dify v0.7.2 也手动到 api/configs/feature/__init__.py。修改了

CODE_MAX_STRING_LENGTH: PositiveInt = Field(
description="max string length for code execution",
default=80000, 修改了default的长度,但是还是报错
The length of output variable result must be less than 30 characters

@leoncool23 commented on GitHub (Aug 28, 2024): > 重复,我们昨天已在此 PR [#7683中修复了此问题](https://github.com/langgenius/dify/pull/7683) > > 与此同时,你可以降级到 v0.7.1。我们将在 v0.7.3 中发布此修复程序 > > 您可以在 docker/.env 中定义此变量 我是上午刚部署的dify v0.7.2 也手动到 api/configs/feature/__init__.py。修改了 CODE_MAX_STRING_LENGTH: PositiveInt = Field( description="max string length for code execution", default=80000, 修改了default的长度,但是还是报错 The length of output variable `result` must be less than 30 characters
Author
Owner

@crazywoola commented on GitHub (Aug 28, 2024):

Duplicated, we already fixed this yesterday in this PR #7683

In the meantime you could downgrade to v0.7.1. We will release this fix in v0.7.3

You can define this variable in docker/.env

You need to update things in .env

@crazywoola commented on GitHub (Aug 28, 2024): > Duplicated, we already fixed this yesterday in this PR #7683 > > In the meantime you could downgrade to v0.7.1. We will release this fix in v0.7.3 > > You can define this variable in docker/.env You need to update things in .env
Author
Owner

@Sure0520 commented on GitHub (Sep 1, 2024):

重复,我们昨天已在此 PR #7683中修复了此问题
与此同时,你可以降级到 v0.7.1。我们将在 v0.7.3 中发布此修复程序
您可以在 docker/.env 中定义此变量

你需要更新 .env 中的内容

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

@Sure0520 commented on GitHub (Sep 1, 2024): > > 重复,我们昨天已在此 PR [#7683中修复了此问题](https://github.com/langgenius/dify/pull/7683) > > 与此同时,你可以降级到 v0.7.1。我们将在 v0.7.3 中发布此修复程序 > > 您可以在 docker/.env 中定义此变量 > > 你需要更新 .env 中的内容 My .env file is also set to 80000, but I still get an error
Author
Owner

@948024326 commented on GitHub (Sep 11, 2024):

重复,我们昨天已在此 PR #7683中修复了此问题
与此同时,你可以降级到 v0.7.1。我们将在 v0.7.3 中发布此修复程序
您可以在 docker/.env 中定义此变量

你需要更新 .env 中的内容

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

did you fix that? my answer is certainly above 80000, can i set a huge number to fix this problem?

@948024326 commented on GitHub (Sep 11, 2024): > > > 重复,我们昨天已在此 PR [#7683中修复了此问题](https://github.com/langgenius/dify/pull/7683) > > > 与此同时,你可以降级到 v0.7.1。我们将在 v0.7.3 中发布此修复程序 > > > 您可以在 docker/.env 中定义此变量 > > > > > > 你需要更新 .env 中的内容 > > My .env file is also set to 80000, but I still get an error did you fix that? my answer is certainly above 80000, can i set a huge number to fix this problem?
Author
Owner

@polhel commented on GitHub (Sep 11, 2024):

Yes, I updated Dify, and now works properly

@polhel commented on GitHub (Sep 11, 2024): Yes, I updated Dify, and now works properly
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#5273