dify icon indicating copy to clipboard operation
dify copied to clipboard

Code block error: operation not permitted with dify-sandbox 0.2.0

Open gijigae opened this issue 9 months ago • 6 comments

Self Checks

  • [X] This is only for bug report, if you would like to ask a question, please head to Discussions.
  • [X] I have searched for existing issues search for existing issues, including closed ones.
  • [X] I confirm that I am using English to submit this report (我已阅读并同意 Language Policy).
  • [X] Please do not modify this template :) and fill in all the required fields.

Dify version

0.6.7

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

git clone the repository and run docker compose up -d. Create a workflow with a Code node and run the workflow.

✔️ Expected Behavior

Workflow should run and return an expected result.

❌ Actual Behavior

The code node returns the following error message. error: operation not permitted

Confirmed the same workflow got executed successfully with an earlier sandbox.

I suspect sandbox 0.2.0 might be a curlprit, which was added as part of #4231 .

https://github.com/langgenius/dify/pull/4231/files#diff-89fafc265c1fa601cf2364b20be83308031335fda9467fcf3249d5ec1c0c8172R373

gijigae avatar May 13 '24 13:05 gijigae

The operation not permitted error you're encountering seems to be related to the sandbox version 0.2.0 update in Dify version 0.6.7. This error typically indicates that the code is attempting to perform operations not allowed within the sandboxed environment. The sandbox restricts certain functionalities for security reasons, including direct file system access, network calls, and operating system-level commands.

Given the changes introduced in sandbox version 0.2.0, as detailed in pull request #4231, it's possible that the code you're executing is now hitting new restrictions. To resolve this, review your code for operations that might be restricted by the sandbox. If your workflow requires functionalities that are restricted, consider using alternative methods within the sandbox's allowed capabilities.

Additionally, check the Docker configuration and settings, as updates in Dify version 0.6.7 could affect the permissions or operations of the Code node within a workflow. The introduction of a dedicated sandbox service for code execution in the Docker configuration might have implications for network access and resource limitations.

If you need to perform operations outside the sandbox's restrictions, Dify documentation suggests using API Based Extension and Code-Based Extension methods to enhance functionality while ensuring security.

Details

Sources


About Dosu This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.

Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.

To continue the conversation, mention @dosu.

dosubot[bot] avatar May 13 '24 13:05 dosubot[bot]

What is the code that you try to run in Code block?

patryk20120 avatar May 13 '24 13:05 patryk20120

Thanks for the comment @patryk20120 ! Here is the workflow, DSL for your reference and the code snippet.

import json

def main(arg1) -> dict:
    # Parse the JSON data
    data = json.loads(arg1)

    # Navigate to the 'transcript' field
    transcript = data['results']['channels'][0]['alternatives'][0]['transcript']
    
    return {
        "result": transcript,
    }
    

gijigae avatar May 13 '24 13:05 gijigae

I cannot reproduce this issue, could you pls provide more information? such as docker ps docker logs and so on. image

Yeuoly avatar May 13 '24 16:05 Yeuoly

Just to confirm, same (success) for me. image

patryk20120 avatar May 13 '24 18:05 patryk20120

I have fixed an issue and updated the image, try pull again? @gijigae

Yeuoly avatar May 13 '24 18:05 Yeuoly

Thanks @Yeuoly for the update! Upgraded to 0.6.8, which includes sandbox 0.2.0, and now everything is looking good.

gijigae avatar May 14 '24 00:05 gijigae