Closed AndyMik90 closed 4 weeks ago
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:
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
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
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
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.
@bowenliang123 @Yeuoly Please take a look at this.
It may require @Yeuoly 's review and futher solutions, since the dify-sandox is not yet part of the open-source project.
We should check the logs for these actions I guess. It seems the sandbox service didn't start successfully. The logs might help
@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.
Self Checks
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