Code block cannot be executed correctly in javascript language #5240

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

Originally created by @shadididi on GitHub (Aug 27, 2024).

Originally assigned to: @Yeuoly on GitHub.

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

Docker version 26.1.3, build b72abbb

  1. follow the guide to start dify service in docker;
  2. create a workflow;
  3. add a code block, and return the input parameter as output;
function main({arg1}) {
    return {
        result: arg1
    }
}
image 5. run it

✔️ Expected Behavior

code block works as expected that returns the correct value of the input parameter

Actual Behavior

code block throws a error error: operation not permitted
image

I have tried to execute code in python and it works fine.

Originally created by @shadididi on GitHub (Aug 27, 2024). Originally assigned to: @Yeuoly on GitHub. ### 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 Docker version 26.1.3, build b72abbb 1. follow the guide to start dify service in docker; 2. create a workflow; 3. add a code block, and return the input parameter as output; ```js function main({arg1}) { return { result: arg1 } } ``` <img width="1236" alt="image" src="https://github.com/user-attachments/assets/f780af37-c78a-40ea-ad01-eb8efd031bf6"> 5. run it ### ✔️ Expected Behavior code block works as expected that returns the correct value of the input parameter ### ❌ Actual Behavior code block throws a error `error: operation not permitted` <img width="463" alt="image" src="https://github.com/user-attachments/assets/d7dd0859-72f3-4478-8324-7c1321ca63cc"> > I have tried to execute code in python and it works fine.
yindo added the 🐞 bug label 2026-02-21 18:10:01 -05:00
yindo closed this issue 2026-02-21 18:10:01 -05:00
Author
Owner

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

@shadididi Hello there! 👋 I'm here to help you with bug reports, answer questions, and guide you to become a contributor. Let's tackle this together!

I found similar issues and discussions related to the "operation not permitted" error in JavaScript code blocks within Dify workflows. Here are some relevant threads and their suggested solutions:

  1. Similar Issues and Discussions:

  2. Suggested Solutions:

    • File Permissions: Ensure that the directories and files mounted into the Docker containers have the correct permissions. The user inside the container should have the necessary permissions to read/write to these directories.
    • Update Docker Compose File: Ensure that the volumes section in your docker-compose.yaml file correctly maps the host directories to the container directories and that the permissions are set correctly.
    • Set Correct Permissions on Host: Use the chmod command to set the correct permissions on the host directories.
    • Run Docker Containers as a Specific User: Try running the Docker containers as a specific user who has the necessary permissions.
    • Convert Files to Unix Format: If you are using Windows, convert certain files to Unix format to avoid permission issues.
  3. JavaScript Code Execution Constraints:
    The "operation not permitted" error in your JavaScript code block is likely due to the restrictions and validations imposed by the DifySandbox environment. Here are some potential reasons:

    • String Length Validation: Ensure that the length of any string output does not exceed dify_config.CODE_MAX_STRING_ARRAY_LENGTH.
    • Number Range Validation: Ensure that any numeric output is within the range defined by dify_config.CODE_MAX_NUMBER and dify_config.CODE_MIN_NUMBER.
    • Precision Validation: Ensure that the precision of floating-point numbers does not exceed dify_config.CODE_MAX_PRECISION.
    • Depth Validation: Ensure that the depth of nested objects does not exceed dify_config.CODE_MAX_DEPTH.
    • Array Length Validation: Ensure that the length of arrays does not exceed the configured limits (dify_config.CODE_MAX_NUMBER_ARRAY_LENGTH, dify_config.CODE_MAX_STRING_ARRAY_LENGTH, dify_config.CODE_MAX_OBJECT_ARRAY_LENGTH).

Review the constraints defined in the dify_config and ensure that your JavaScript code adheres to these constraints. Additionally, ensure that your code does not attempt to perform any restricted operations that are not permitted in the sandboxed environment [1][2][3].

To continue talking to Dosu, mention @dosu.

@dosubot[bot] commented on GitHub (Aug 27, 2024): <!-- Greeting --> @shadididi Hello there! 👋 I'm here to help you with bug reports, answer questions, and guide you to become a contributor. Let's tackle this together! <!-- Answer --> I found similar issues and discussions related to the "operation not permitted" error in JavaScript code blocks within Dify workflows. Here are some relevant threads and their suggested solutions: 1. **Similar Issues and Discussions**: - [Node 代码执行 run failed: error: operation not permitted](https://github.com/langgenius/dify/discussions/3933) (Unsolved) <sup>[[1]](https://github.com/langgenius/dify/discussions/3933)</sup> - [error: operation not permitted](https://github.com/langgenius/dify/issues/4993) (Closed) <sup>[[2]](https://github.com/langgenius/dify/issues/4993)</sup> - [When I used the new version 0.68 and the 0.20 sandbox, I still encountered workflow errors: error: operation not permitted](https://github.com/langgenius/dify/issues/4576) (Closed) <sup>[[3]](https://github.com/langgenius/dify/issues/4576)</sup> 2. **Suggested Solutions**: - **File Permissions**: Ensure that the directories and files mounted into the Docker containers have the correct permissions. The user inside the container should have the necessary permissions to read/write to these directories. - **Update Docker Compose File**: Ensure that the `volumes` section in your `docker-compose.yaml` file correctly maps the host directories to the container directories and that the permissions are set correctly. - **Set Correct Permissions on Host**: Use the `chmod` command to set the correct permissions on the host directories. - **Run Docker Containers as a Specific User**: Try running the Docker containers as a specific user who has the necessary permissions. - **Convert Files to Unix Format**: If you are using Windows, convert certain files to Unix format to avoid permission issues. 3. **JavaScript Code Execution Constraints**: The "operation not permitted" error in your JavaScript code block is likely due to the restrictions and validations imposed by the `DifySandbox` environment. Here are some potential reasons: - **String Length Validation**: Ensure that the length of any string output does not exceed `dify_config.CODE_MAX_STRING_ARRAY_LENGTH`. - **Number Range Validation**: Ensure that any numeric output is within the range defined by `dify_config.CODE_MAX_NUMBER` and `dify_config.CODE_MIN_NUMBER`. - **Precision Validation**: Ensure that the precision of floating-point numbers does not exceed `dify_config.CODE_MAX_PRECISION`. - **Depth Validation**: Ensure that the depth of nested objects does not exceed `dify_config.CODE_MAX_DEPTH`. - **Array Length Validation**: Ensure that the length of arrays does not exceed the configured limits (`dify_config.CODE_MAX_NUMBER_ARRAY_LENGTH`, `dify_config.CODE_MAX_STRING_ARRAY_LENGTH`, `dify_config.CODE_MAX_OBJECT_ARRAY_LENGTH`). Review the constraints defined in the `dify_config` and ensure that your JavaScript code adheres to these constraints. Additionally, ensure that your code does not attempt to perform any restricted operations that are not permitted in the sandboxed environment <sup>[[1]](https://github.com/langgenius/dify/discussions/3933)</sup><sup>[[2]](https://github.com/langgenius/dify/issues/4993)</sup><sup>[[3]](https://github.com/langgenius/dify/issues/4576)</sup>. <!-- Dosu Comment Footer --> *To continue talking to [Dosu](https://dosu.dev), mention @dosu.*
Author
Owner

@moyueheng commented on GitHub (Aug 27, 2024):

I was unable to reproduce it using version 0.7.2.
image

image
@moyueheng commented on GitHub (Aug 27, 2024): I was unable to reproduce it using version 0.7.2. <img width="464" alt="image" src="https://github.com/user-attachments/assets/5c98e241-0c55-4933-ac2a-a1993e03f2d8"> <img width="462" alt="image" src="https://github.com/user-attachments/assets/b4f67eb8-8dd6-401d-94ec-b30a3c8f36dd">
Author
Owner

@shadididi commented on GitHub (Aug 27, 2024):

I was unable to reproduce it using version 0.7.2. image

image

that was confusing, just doesn't work in JS. I manually download the source file with tag 0.7.2 in my Mac, and just enter the docker dir of the project, execute docker compose up -d. Are there some steps that I missed?

@shadididi commented on GitHub (Aug 27, 2024): > I was unable to reproduce it using version 0.7.2. <img alt="image" width="464" src="https://private-user-images.githubusercontent.com/54298540/361740470-5c98e241-0c55-4933-ac2a-a1993e03f2d8.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjQ3NTE5MDksIm5iZiI6MTcyNDc1MTYwOSwicGF0aCI6Ii81NDI5ODU0MC8zNjE3NDA0NzAtNWM5OGUyNDEtMGM1NS00OTMzLWFjMmEtYTE5OTNlMDNmMmQ4LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA4MjclMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwODI3VDA5NDAwOVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTVjNGVjMzdkY2RkN2VjYTQxNGM4YTc4ZTRmOTAxNGY2NWFkZDEwMzZhMmNhYzRmZmM3ZGE2MTg0ZTRmOTdlYWMmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.K17lC3Dj8RlQcmbQoEtHbrA1ciYhjKRjFbwaBSk22sY"> > > <img alt="image" width="462" src="https://private-user-images.githubusercontent.com/54298540/361740956-b4f67eb8-8dd6-401d-94ec-b30a3c8f36dd.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjQ3NTE5MDksIm5iZiI6MTcyNDc1MTYwOSwicGF0aCI6Ii81NDI5ODU0MC8zNjE3NDA5NTYtYjRmNjdlYjgtOGRkNi00MDFkLTk0ZWMtYjMwYTNjOGYzNmRkLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA4MjclMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwODI3VDA5NDAwOVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTdjM2MyYWMwMzk3OTA2ZTM3OTZkMTEwNWJhYzdiODc1ZDYzMDE3YjViM2E5NWUwNGYyZDI2ZmRhZTllOGZkZmMmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.QtUrmnr4muVYUy_tQGKjp1PVhnhxiNUBaHgFWOuRSqc"> that was confusing, just doesn't work in JS. I manually download the source file with tag 0.7.2 in my Mac, and just enter the docker dir of the project, execute `docker compose up -d`. Are there some steps that I missed?
Author
Owner

@sulgweb commented on GitHub (Aug 27, 2024):

image same error. mac m1 pro,dify verision 0.7.2,Docker version 26.1.3, build b72abbb
@sulgweb commented on GitHub (Aug 27, 2024): <img width="1169" alt="image" src="https://github.com/user-attachments/assets/2bde350e-c517-4ab2-a138-e0a280b26086"> same error. mac m1 pro,dify verision 0.7.2,Docker version 26.1.3, build b72abbb
Author
Owner

@moyueheng commented on GitHub (Aug 27, 2024):

I was unable to reproduce it using version 0.7.2. image
image

that was confusing, just doesn't work in JS. I manually download the source file with tag 0.7.2 in my Mac, and just enter the docker dir of the project, execute docker compose up -d. Are there some steps that I missed?

My deployment method is consistent with yours. My environment is Ubuntu 20.04, docker 26.0.0. dify 0.7.2
image

@moyueheng commented on GitHub (Aug 27, 2024): > > I was unable to reproduce it using version 0.7.2. <img alt="image" width="55.1484375" height="21" src="https://private-user-images.githubusercontent.com/54298540/361740470-5c98e241-0c55-4933-ac2a-a1993e03f2d8.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjQ3NTE5MDksIm5iZiI6MTcyNDc1MTYwOSwicGF0aCI6Ii81NDI5ODU0MC8zNjE3NDA0NzAtNWM5OGUyNDEtMGM1NS00OTMzLWFjMmEtYTE5OTNlMDNmMmQ4LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA4MjclMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwODI3VDA5NDAwOVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTVjNGVjMzdkY2RkN2VjYTQxNGM4YTc4ZTRmOTAxNGY2NWFkZDEwMzZhMmNhYzRmZmM3ZGE2MTg0ZTRmOTdlYWMmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.K17lC3Dj8RlQcmbQoEtHbrA1ciYhjKRjFbwaBSk22sY"> > > <img alt="image" width="55.1484375" height="21" src="https://private-user-images.githubusercontent.com/54298540/361740956-b4f67eb8-8dd6-401d-94ec-b30a3c8f36dd.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjQ3NTE5MDksIm5iZiI6MTcyNDc1MTYwOSwicGF0aCI6Ii81NDI5ODU0MC8zNjE3NDA5NTYtYjRmNjdlYjgtOGRkNi00MDFkLTk0ZWMtYjMwYTNjOGYzNmRkLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA4MjclMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwODI3VDA5NDAwOVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTdjM2MyYWMwMzk3OTA2ZTM3OTZkMTEwNWJhYzdiODc1ZDYzMDE3YjViM2E5NWUwNGYyZDI2ZmRhZTllOGZkZmMmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.QtUrmnr4muVYUy_tQGKjp1PVhnhxiNUBaHgFWOuRSqc"> > > that was confusing, just doesn't work in JS. I manually download the source file with tag 0.7.2 in my Mac, and just enter the docker dir of the project, execute `docker compose up -d`. Are there some steps that I missed? My deployment method is consistent with yours. My environment is Ubuntu 20.04, docker 26.0.0. dify 0.7.2 <img width="1716" alt="image" src="https://github.com/user-attachments/assets/05c44546-36a2-461d-b439-da0c95415f6d">
Author
Owner

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

same version same issue here

@jojotechs commented on GitHub (Aug 28, 2024): same version same issue here
Author
Owner

@crazywoola commented on GitHub (Sep 6, 2024):

Cant reproduce this as well, what's yours' sandbox version. Please try to upgrade to 0.2.6 @jojotechs @sulgweb @shadididi

@crazywoola commented on GitHub (Sep 6, 2024): Cant reproduce this as well, what's yours' sandbox version. Please try to upgrade to 0.2.6 @jojotechs @sulgweb @shadididi
Author
Owner

@shadididi commented on GitHub (Sep 6, 2024):

Cant reproduce this as well, what's yours' sandbox version. Please try to upgrade to 0.2.6 @jojotechs @sulgweb @shadididi

sandbox version is already 0.2.6

@shadididi commented on GitHub (Sep 6, 2024): > Cant reproduce this as well, what's yours' sandbox version. Please try to upgrade to 0.2.6 @jojotechs @sulgweb @shadididi sandbox version is already 0.2.6
Author
Owner

@Yeuoly commented on GitHub (Sep 6, 2024):

Sorry for the confusion, but I can not reproduce this issue after several tries, and basic checks for nodejs all passes on Github actions, I have no idea which permission missed on your machine.

@Yeuoly commented on GitHub (Sep 6, 2024): Sorry for the confusion, but I can not reproduce this issue after several tries, and basic checks for nodejs all passes on Github actions, I have no idea which permission missed on your machine.
Author
Owner

@shadididi commented on GitHub (Sep 7, 2024):

Sorry for the confusion, but I can not reproduce this issue after several tries, and basic checks for nodejs all passes on Github actions, I have no idea which permission missed on your machine.

Have you tried in Mac machines ? I noticed that others have same problem in Mac m1 pro.

@shadididi commented on GitHub (Sep 7, 2024): > Sorry for the confusion, but I can not reproduce this issue after several tries, and basic checks for nodejs all passes on Github actions, I have no idea which permission missed on your machine. Have you tried in Mac machines ? I noticed that others have same problem in Mac m1 pro.
Author
Owner

@Yeuoly commented on GitHub (Sep 8, 2024):

Sorry for the confusion, but I can not reproduce this issue after several tries, and basic checks for nodejs all passes on Github actions, I have no idea which permission missed on your machine.

Have you tried in Mac machines ? I noticed that others have same problem in Mac m1 pro.

I'm currently using Mac M2, maybe it's an issue related to chips? I'm not sure, I do not have a machine with M1 right now.

@Yeuoly commented on GitHub (Sep 8, 2024): > > Sorry for the confusion, but I can not reproduce this issue after several tries, and basic checks for nodejs all passes on Github actions, I have no idea which permission missed on your machine. > > Have you tried in Mac machines ? I noticed that others have same problem in Mac m1 pro. I'm currently using Mac M2, maybe it's an issue related to chips? I'm not sure, I do not have a machine with M1 right now.
Author
Owner

@walkwolf commented on GitHub (Sep 10, 2024):

I have same problom on mac m1 after update to 0.7.3. sandbox image: langgenius/dify-sandbox:0.2.7

@walkwolf commented on GitHub (Sep 10, 2024): I have same problom on mac m1 after update to 0.7.3. sandbox image: langgenius/dify-sandbox:0.2.7
Author
Owner

@fengwk commented on GitHub (Nov 18, 2025):

@shadididi Hello there! 👋 I'm here to help you with bug reports, answer questions, and guide you to become a contributor. Let's tackle this together@shadididi 你好!👋 我可以帮你处理错误报告、解答问题,并指导你成为一名贡献者。让我们一起解决问题吧!

I found similar issues and discussions related to the "operation not permitted" error in JavaScript code blocks within Dify workflows. Here are some relevant threads and their suggested solutions:我发现了一些与Dify工作流中JavaScript代码块出现“操作不允许”错误相关的类似问题和讨论。以下是一些相关的帖子及其建议的解决方案:

  1. Similar Issues and Discussions: 类似问题和讨论

  2. Suggested Solutions: 建议的解决方案

    • File Permissions: Ensure that the directories and files mounted into the Docker containers have the correct permissions. The user inside the container should have the necessary permissions to read/write to these directories.文件权限:确保挂载到Docker容器中的目录和文件具有正确的权限。容器内的用户应具备对这些目录进行读写的必要权限。
    • Update Docker Compose File: Ensure that the volumes section in your docker-compose.yaml file correctly maps the host directories to the container directories and that the permissions are set correctly.更新Docker Compose文件:确保docker-compose.yaml文件中的volumes部分正确将主机目录映射到容器目录,并且权限设置正确。
    • Set Correct Permissions on Host: Use the chmod command to set the correct permissions on the host directories.在主机上设置正确的权限:使用chmod命令在主机目录上设置正确的权限。
    • Run Docker Containers as a Specific User: Try running the Docker containers as a specific user who has the necessary permissions.以特定用户身份运行Docker容器:尝试以具有必要权限的特定用户身份运行Docker容器。
    • Convert Files to Unix Format: If you are using Windows, convert certain files to Unix format to avoid permission issues.将文件转换为Unix格式:如果您使用的是Windows,请将某些文件转换为Unix格式,以避免权限问题。
  3. JavaScript Code Execution Constraints:JavaScript代码执行限制
    The "operation not permitted" error in your JavaScript code block is likely due to the restrictions and validations imposed by the 你的JavaScript代码块中出现的“操作不被允许”错误可能是由于所施加的限制和验证导致的。DifySandbox environment. Here are some potential reasons:环境。以下是一些可能的原因:

    • String Length Validation: Ensure that the length of any string output does not exceed dify_config.CODE_MAX_STRING_ARRAY_LENGTH.字符串长度验证:确保任何字符串输出的长度不超过dify_config.CODE_MAX_STRING_ARRAY_LENGTH
    • Number Range Validation: Ensure that any numeric output is within the range defined by dify_config.CODE_MAX_NUMBER and dify_config.CODE_MIN_NUMBER.数字范围验证:确保任何数字输出都在dify_config.CODE_MAX_NUMBERdify_config.CODE_MIN_NUMBER定义的范围内。
    • Precision Validation: Ensure that the precision of floating-point numbers does not exceed dify_config.CODE_MAX_PRECISION.精度验证:确保浮点数的精度不超过dify_config.CODE_MAX_PRECISION
    • Depth Validation: Ensure that the depth of nested objects does not exceed dify_config.CODE_MAX_DEPTH.深度验证:确保嵌套对象的深度不超过dify_config.CODE_MAX_DEPTH
    • Array Length Validation: Ensure that the length of arrays does not exceed the configured limits (dify_config.CODE_MAX_NUMBER_ARRAY_LENGTH, dify_config.CODE_MAX_STRING_ARRAY_LENGTH, dify_config.CODE_MAX_OBJECT_ARRAY_LENGTH).数组长度验证:确保数组的长度不超过配置的限制(dify_config.CODE_MAX_NUMBER_ARRAY_LENGTHdify_config.CODE_MAX_STRING_ARRAY_LENGTHdify_config.CODE_MAX_OBJECT_ARRAY_LENGTH)。

Review the constraints defined in the dify_config and ensure that your JavaScript code adheres to these constraints. Additionally, ensure that your code does not attempt to perform any restricted operations that are not permitted in the sandboxed environment [1][2][3].检查dify_config中定义的约束条件,并确保你的JavaScript代码遵守这些约束。此外,确保你的代码不会尝试执行沙箱环境中不允许的任何受限操作[1][2][3]

To continue talking to Dosu, mention @dosu.要继续与Dosu交谈,请提及@dosu

Image

I am very confused as to why such a simple Python script occasionally throws an "error: operation not permitted" error, which clearly should not involve system calls.

Although this is an occasional problem, it will cause a large workflow to be terminated frequently, which is a very bad experience.

here is script

def main(lenStr: str):
    return {
        "result": int(lenStr),
    }
@fengwk commented on GitHub (Nov 18, 2025): > [@shadididi](https://github.com/shadididi) Hello there! 👋 I'm here to help you with bug reports, answer questions, and guide you to become a contributor. Let's tackle this together![@shadididi](https://github.com/shadididi) 你好!👋 我可以帮你处理错误报告、解答问题,并指导你成为一名贡献者。让我们一起解决问题吧! > > I found similar issues and discussions related to the "operation not permitted" error in JavaScript code blocks within Dify workflows. Here are some relevant threads and their suggested solutions:我发现了一些与Dify工作流中JavaScript代码块出现“操作不允许”错误相关的类似问题和讨论。以下是一些相关的帖子及其建议的解决方案: > > 1. **Similar Issues and Discussions**: **类似问题和讨论**: > > * [Node 代码执行 run failed: error: operation not permitted](https://github.com/langgenius/dify/discussions/3933) (Unsolved) [[1]](https://github.com/langgenius/dify/discussions/3933)[节点代码执行运行失败:错误:操作不允许](https://github.com/langgenius/dify/discussions/3933)(未解决)[[1]](https://github.com/langgenius/dify/discussions/3933) > * [error: operation not permitted](https://github.com/langgenius/dify/issues/4993) (Closed) [[2]](https://github.com/langgenius/dify/issues/4993)[错误:操作不允许](https://github.com/langgenius/dify/issues/4993)(已关闭)[[2]](https://github.com/langgenius/dify/issues/4993) > * [When I used the new version 0.68 and the 0.20 sandbox, I still encountered workflow errors: error: operation not permitted](https://github.com/langgenius/dify/issues/4576) (Closed) [[3]](https://github.com/langgenius/dify/issues/4576)[当我使用新版本0.68和0.20沙箱时,仍然遇到了工作流错误:错误:操作不被允许](https://github.com/langgenius/dify/issues/4576)(已关闭)[[3]](https://github.com/langgenius/dify/issues/4576) > 2. **Suggested Solutions**: **建议的解决方案**: > > * **File Permissions**: Ensure that the directories and files mounted into the Docker containers have the correct permissions. The user inside the container should have the necessary permissions to read/write to these directories.**文件权限**:确保挂载到Docker容器中的目录和文件具有正确的权限。容器内的用户应具备对这些目录进行读写的必要权限。 > * **Update Docker Compose File**: Ensure that the `volumes` section in your `docker-compose.yaml` file correctly maps the host directories to the container directories and that the permissions are set correctly.**更新Docker Compose文件**:确保`docker-compose.yaml`文件中的`volumes`部分正确将主机目录映射到容器目录,并且权限设置正确。 > * **Set Correct Permissions on Host**: Use the `chmod` command to set the correct permissions on the host directories.**在主机上设置正确的权限**:使用`chmod`命令在主机目录上设置正确的权限。 > * **Run Docker Containers as a Specific User**: Try running the Docker containers as a specific user who has the necessary permissions.**以特定用户身份运行Docker容器**:尝试以具有必要权限的特定用户身份运行Docker容器。 > * **Convert Files to Unix Format**: If you are using Windows, convert certain files to Unix format to avoid permission issues.**将文件转换为Unix格式**:如果您使用的是Windows,请将某些文件转换为Unix格式,以避免权限问题。 > 3. **JavaScript Code Execution Constraints**:**JavaScript代码执行限制**: > The "operation not permitted" error in your JavaScript code block is likely due to the restrictions and validations imposed by the 你的JavaScript代码块中出现的“操作不被允许”错误可能是由于所施加的限制和验证导致的。`DifySandbox` environment. Here are some potential reasons:环境。以下是一些可能的原因: > > * **String Length Validation**: Ensure that the length of any string output does not exceed `dify_config.CODE_MAX_STRING_ARRAY_LENGTH`.**字符串长度验证**:确保任何字符串输出的长度不超过`dify_config.CODE_MAX_STRING_ARRAY_LENGTH`。 > * **Number Range Validation**: Ensure that any numeric output is within the range defined by `dify_config.CODE_MAX_NUMBER` and `dify_config.CODE_MIN_NUMBER`.**数字范围验证**:确保任何数字输出都在`dify_config.CODE_MAX_NUMBER`和`dify_config.CODE_MIN_NUMBER`定义的范围内。 > * **Precision Validation**: Ensure that the precision of floating-point numbers does not exceed `dify_config.CODE_MAX_PRECISION`.**精度验证**:确保浮点数的精度不超过`dify_config.CODE_MAX_PRECISION`。 > * **Depth Validation**: Ensure that the depth of nested objects does not exceed `dify_config.CODE_MAX_DEPTH`.**深度验证**:确保嵌套对象的深度不超过`dify_config.CODE_MAX_DEPTH`。 > * **Array Length Validation**: Ensure that the length of arrays does not exceed the configured limits (`dify_config.CODE_MAX_NUMBER_ARRAY_LENGTH`, `dify_config.CODE_MAX_STRING_ARRAY_LENGTH`, `dify_config.CODE_MAX_OBJECT_ARRAY_LENGTH`).**数组长度验证**:确保数组的长度不超过配置的限制(`dify_config.CODE_MAX_NUMBER_ARRAY_LENGTH`、`dify_config.CODE_MAX_STRING_ARRAY_LENGTH`、`dify_config.CODE_MAX_OBJECT_ARRAY_LENGTH`)。 > > Review the constraints defined in the `dify_config` and ensure that your JavaScript code adheres to these constraints. Additionally, ensure that your code does not attempt to perform any restricted operations that are not permitted in the sandboxed environment [[1]](https://github.com/langgenius/dify/discussions/3933)[[2]](https://github.com/langgenius/dify/issues/4993)[[3]](https://github.com/langgenius/dify/issues/4576).检查`dify_config`中定义的约束条件,并确保你的JavaScript代码遵守这些约束。此外,确保你的代码不会尝试执行沙箱环境中不允许的任何受限操作[[1]](https://github.com/langgenius/dify/discussions/3933)[[2]](https://github.com/langgenius/dify/issues/4993)[[3]](https://github.com/langgenius/dify/issues/4576)。 > > _To continue talking to [Dosu](https://dosu.dev), mention [@dosu](https://github.com/dosu).要继续与[Dosu](https://dosu.dev)交谈,请提及[@dosu](https://github.com/dosu)。_ <img width="3021" height="1685" alt="Image" src="https://github.com/user-attachments/assets/1bd91830-4ea4-48c7-9971-93f223f7fba8" /> I am very confused as to why such a simple Python script occasionally throws an "error: operation not permitted" error, which clearly should not involve system calls. Although this is an occasional problem, it will cause a large workflow to be terminated frequently, which is a very bad experience. here is script ``` def main(lenStr: str): return { "result": int(lenStr), } ```
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#5240