Adding python requirements to sandbox gives Github Action error #4004

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

Originally created by @AndyMik90 on GitHub (Jun 6, 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).
  • Please do not modify this template :) and fill in all the required fields.

Dify version

0.6.10

Cloud or Self Hosted

Self Hosted (Docker), Self Hosted (Source)

Steps to reproduce

Add dependencies to docker/volumes/sandbox/dependencies/python-requirements.txt
"requests
jinja2
httpx"

When API Test 3.10 and 3.11 run in github action, it gives error on the code excecution:
=========================== short test summary info ============================
FAILED api/tests/integration_tests/workflow/nodes/code_executor/test_code_javascript.py::test_javascript_plain - core.helper.code_executor.code_executor.CodeExecutionException: Failed to execute code, which is likely a network issue, please check if the sandbox service is running. ( Error: Failed to execute code, got status code 502, please check if the sandbox service is running )

✔️ Expected Behavior

The sanbox works locally and on AWS ECS with these dependencies, and we are relying on them in the python-requirements.txt since our sandbox is deployed by itself and not with docker.

Actual Behavior

Gives code excecution errors on api checks

Originally created by @AndyMik90 on GitHub (Jun 6, 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] Please do not modify this template :) and fill in all the required fields. ### Dify version 0.6.10 ### Cloud or Self Hosted Self Hosted (Docker), Self Hosted (Source) ### Steps to reproduce Add dependencies to docker/volumes/sandbox/dependencies/python-requirements.txt "requests jinja2 httpx" When API Test 3.10 and 3.11 run in github action, it gives error on the code excecution: =========================== short test summary info ============================ FAILED api/tests/integration_tests/workflow/nodes/code_executor/test_code_javascript.py::test_javascript_plain - core.helper.code_executor.code_executor.CodeExecutionException: Failed to execute code, which is likely a network issue, please check if the sandbox service is running. ( Error: Failed to execute code, got status code 502, please check if the sandbox service is running ) ### ✔️ Expected Behavior The sanbox works locally and on AWS ECS with these dependencies, and we are relying on them in the python-requirements.txt since our sandbox is deployed by itself and not with docker. ### ❌ Actual Behavior Gives code excecution errors on api checks
yindo added the 🐞 bug label 2026-02-21 18:04:21 -05:00
yindo closed this issue 2026-02-21 18:04:21 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Jun 6, 2024):

To resolve the code execution errors in GitHub Actions when adding Python requirements to the sandbox, given the error message indicating a potential network issue with the sandbox service, you should ensure that the sandbox service is running and accessible. Here are the steps to troubleshoot and resolve the issue:

  1. Check if the sandbox service is running: Ensure that the service at CODE_EXECUTION_ENDPOINT is up and running. According to the docker-compose.yaml file, the sandbox service should be configured as follows:

    sandbox:
      image: langgenius/dify-sandbox:0.2.1
      restart: always
      environment:
        API_KEY: dify-sandbox
        GIN_MODE: 'release'
        WORKER_TIMEOUT: 15
        ENABLE_NETWORK: 'true'
        HTTP_PROXY: 'http://ssrf_proxy:3128'
        HTTPS_PROXY: 'http://ssrf_proxy:3128'
        SANDBOX_PORT: 8194
      volumes:
        - ./volumes/sandbox/dependencies:/dependencies
      networks:
        - ssrf_proxy_network
    
  2. Verify network connectivity: Make sure there are no network issues preventing access to the sandbox service. The ssrf_proxy service is used to manage network access:

    ssrf_proxy:
      image: ubuntu/squid:latest
      restart: always
      volumes:
        - ./volumes/ssrf_proxy/squid.conf:/etc/squid/squid.conf
      networks:
        - ssrf_proxy_network
        - default
    
  3. Check API Key: Ensure that CODE_EXECUTION_API_KEY is correctly set and has the necessary permissions. The API key should match the one configured in the sandbox service:

    CODE_EXECUTION_API_KEY: dify-sandbox
    
  4. Enable detailed logging: Set the LOG_LEVEL to DEBUG to enable more verbose logging for the sandbox service. This can help in diagnosing network issues or service unavailability:

    sandbox:
      image: langgenius/dify-sandbox:0.2.1
      restart: always
      environment:
        API_KEY: dify-sandbox
        GIN_MODE: 'release'
        WORKER_TIMEOUT: 15
        ENABLE_NETWORK: 'true'
        HTTP_PROXY: 'http://ssrf_proxy:3128'
        HTTPS_PROXY: 'http://ssrf_proxy:3128'
        SANDBOX_PORT: 8194
        LOG_LEVEL: DEBUG  # Set log level to DEBUG for detailed logging
      volumes:
        - ./volumes/sandbox/dependencies:/dependencies
      networks:
        - ssrf_proxy_network
    

If the service is running and network connectivity is confirmed, but the issue persists, you may need to investigate further into the sandbox service logs for any specific errors [1][2].

To continue talking to Dosu, mention @dosu.

@dosubot[bot] commented on GitHub (Jun 6, 2024): <!-- Answer --> To resolve the code execution errors in GitHub Actions when adding Python requirements to the sandbox, given the error message indicating a potential network issue with the sandbox service, you should ensure that the sandbox service is running and accessible. Here are the steps to troubleshoot and resolve the issue: 1. **Check if the sandbox service is running**: Ensure that the service at `CODE_EXECUTION_ENDPOINT` is up and running. According to the `docker-compose.yaml` file, the sandbox service should be configured as follows: ```yaml sandbox: image: langgenius/dify-sandbox:0.2.1 restart: always environment: API_KEY: dify-sandbox GIN_MODE: 'release' WORKER_TIMEOUT: 15 ENABLE_NETWORK: 'true' HTTP_PROXY: 'http://ssrf_proxy:3128' HTTPS_PROXY: 'http://ssrf_proxy:3128' SANDBOX_PORT: 8194 volumes: - ./volumes/sandbox/dependencies:/dependencies networks: - ssrf_proxy_network ``` 2. **Verify network connectivity**: Make sure there are no network issues preventing access to the sandbox service. The `ssrf_proxy` service is used to manage network access: ```yaml ssrf_proxy: image: ubuntu/squid:latest restart: always volumes: - ./volumes/ssrf_proxy/squid.conf:/etc/squid/squid.conf networks: - ssrf_proxy_network - default ``` 3. **Check API Key**: Ensure that `CODE_EXECUTION_API_KEY` is correctly set and has the necessary permissions. The API key should match the one configured in the sandbox service: ```yaml CODE_EXECUTION_API_KEY: dify-sandbox ``` 4. **Enable detailed logging**: Set the `LOG_LEVEL` to `DEBUG` to enable more verbose logging for the sandbox service. This can help in diagnosing network issues or service unavailability: ```yaml sandbox: image: langgenius/dify-sandbox:0.2.1 restart: always environment: API_KEY: dify-sandbox GIN_MODE: 'release' WORKER_TIMEOUT: 15 ENABLE_NETWORK: 'true' HTTP_PROXY: 'http://ssrf_proxy:3128' HTTPS_PROXY: 'http://ssrf_proxy:3128' SANDBOX_PORT: 8194 LOG_LEVEL: DEBUG # Set log level to DEBUG for detailed logging volumes: - ./volumes/sandbox/dependencies:/dependencies networks: - ssrf_proxy_network ``` If the service is running and network connectivity is confirmed, but the issue persists, you may need to investigate further into the sandbox service logs for any specific errors <sup>[[1]](https://github.com/langgenius/dify/blob/main/api/core/helper/code_executor/code_executor.py)</sup><sup>[[2]](https://github.com/langgenius/dify/blob/main/docker/docker-compose.yaml)</sup>. <!-- Dosu Comment Footer --> *To continue talking to [Dosu](https://dosu.dev), mention @dosu.*
Author
Owner

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

@bowenliang123 @Yeuoly Please take a look at this.

@crazywoola commented on GitHub (Jun 6, 2024): @bowenliang123 @Yeuoly Please take a look at this.
Author
Owner

@bowenliang123 commented on GitHub (Jun 6, 2024):

It may require @Yeuoly 's review and futher solutions, since the dify-sandox is not yet part of the open-source project.

@bowenliang123 commented on GitHub (Jun 6, 2024): It may require @Yeuoly 's review and futher solutions, since the dify-sandox is not yet part of the open-source project.
Author
Owner

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

We should check the logs for these actions I guess. It seems the sandbox service didn't start successfully. The logs might help

@Yeuoly commented on GitHub (Jun 6, 2024): We should check the logs for these actions I guess. It seems the sandbox service didn't start successfully. The logs might help
Author
Owner

@AndyMik90 commented on GitHub (Jun 6, 2024):

@Yeuoly @bowenliang123 So the sandbox itself seems to be running:

36446b6ba251 Pull complete
sandbox Pulled
Network docker_ssrf_proxy_network Creating
Network docker_ssrf_proxy_network Created
Network docker_default Creating
Network docker_default Created
Container docker-ssrf_proxy-1 Creating
Container docker-sandbox-1 Creating
Container docker-sandbox-1 Created
Container docker-ssrf_proxy-1 Created
Container docker-ssrf_proxy-1 Starting
Container docker-sandbox-1 Starting
Container docker-sandbox-1 Started
Container docker-ssrf_proxy-1 Started
docker-compose is up

when I removed the dependencies from the docker/volumes/sandbox/dependencies/python-requirements.txt, the GitHub action goes through with no problem.

@AndyMik90 commented on GitHub (Jun 6, 2024): @Yeuoly @bowenliang123 So the sandbox itself seems to be running: 36446b6ba251 Pull complete sandbox Pulled Network docker_ssrf_proxy_network Creating Network docker_ssrf_proxy_network Created Network docker_default Creating Network docker_default Created Container docker-ssrf_proxy-1 Creating Container docker-sandbox-1 Creating Container docker-sandbox-1 Created Container docker-ssrf_proxy-1 Created Container docker-ssrf_proxy-1 Starting Container docker-sandbox-1 Starting Container docker-sandbox-1 Started Container docker-ssrf_proxy-1 Started docker-compose is up when I removed the dependencies from the docker/volumes/sandbox/dependencies/python-requirements.txt, the GitHub action goes through with no problem.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#4004