Problem Description
When passing custom environment variables via SandboxSpec.template.environment, these variables do not appear in the sandbox container's environment.
Reproduction Steps
- Create a sandbox with environment variables using the Python SDK:
sandbox = client.create_sandbox(
name="test-env",
source="base",
environment={
"GATEWAY_URL": "http://10.156.113.180:8001",
"GATEWAY_API_KEY": "test-key",
"SANDBOX_ID": "test-env",
},
)
-
Debug output confirms the environment variables are correctly serialized in the protobuf message (request.spec.template.environment contains these values)
-
After the sandbox is ready, run env inside the sandbox:
env | grep GATEWAY
# no output - environment variables are missing
Expected Behavior
Environment variables in template.environment should appear in the container's environment.
Actual Behavior
- Debug output confirms
template.environment is correctly passed to the OpenShell server
- But running
env shows no custom environment variables
- OpenShell default environment variables (like
OPENSHELL_SANDBOX_ID, SSL_CERT_FILE, etc.) do appear
Verification Steps Taken
- prost protobuf serialization is correct:
request.spec.template.environment contains all environment variables
- Rust
build_env_list function should process template_environment: it calls apply_env_map(&mut env, template_environment)
apply_env_map should upsert environment variables
- Tested with a simple
MY_TEST_VAR=test_value - same result, environment variable not present
Environment
Related Code
crates/openshell-server/src/sandbox/mod.rs:
sandbox_template_to_k8s receives template_environment: &HashMap<String, String>
build_env_list calls apply_env_map(&mut env, template_environment)
apply_env_map should upsert environment variables
Possible Causes
- prost deserialization issue with
map<string, string> fields
- Kubernetes-level environment variable injection issue
- Or
template.environment support was never fully implemented
Related issues: #848 (similar environment variable issue)
Problem Description
When passing custom environment variables via
SandboxSpec.template.environment, these variables do not appear in the sandbox container's environment.Reproduction Steps
Debug output confirms the environment variables are correctly serialized in the protobuf message (
request.spec.template.environmentcontains these values)After the sandbox is ready, run
envinside the sandbox:Expected Behavior
Environment variables in
template.environmentshould appear in the container's environment.Actual Behavior
template.environmentis correctly passed to the OpenShell serverenvshows no custom environment variablesOPENSHELL_SANDBOX_ID,SSL_CERT_FILE, etc.) do appearVerification Steps Taken
request.spec.template.environmentcontains all environment variablesbuild_env_listfunction should processtemplate_environment: it callsapply_env_map(&mut env, template_environment)apply_env_mapshould upsert environment variablesMY_TEST_VAR=test_value- same result, environment variable not presentEnvironment
OPENSHELL_SANDBOX_COMMANDvia theenvironmentmap and it didn't workRelated Code
crates/openshell-server/src/sandbox/mod.rs:sandbox_template_to_k8sreceivestemplate_environment: &HashMap<String, String>build_env_listcallsapply_env_map(&mut env, template_environment)apply_env_mapshould upsert environment variablesPossible Causes
map<string, string>fieldstemplate.environmentsupport was never fully implementedRelated issues: #848 (similar environment variable issue)