Skip to content

[Question] SandboxTemplate.environment environment variables not applied to container #863

Closed

Description

@derekhsu

Problem Description

When passing custom environment variables via SandboxSpec.template.environment, these variables do not appear in the sandbox container's environment.

Reproduction Steps

  1. 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",
    },
)
  1. Debug output confirms the environment variables are correctly serialized in the protobuf message (request.spec.template.environment contains these values)

  2. 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

  1. prost deserialization issue with map<string, string> fields
  2. Kubernetes-level environment variable injection issue
  3. Or template.environment support was never fully implemented

Related issues: #848 (similar environment variable issue)

Activity

  1. changed the title [-][問題] SandboxTemplate.environment 環境變數未被正確應用到容器[/-] [+][Question] SandboxTemplate.environment environment variables not applied to container[/+] on Apr 16, 2026
  2. self-assigned this
    on Apr 22, 2026
  3. github-actions commented on Aug 30, 2026

    @github-actions

    This issue has had no activity for 14 days and is now marked stale. It may be closed in 7 days if there is no further activity. Comment or remove the state:stale label to keep it open.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

state:staleInactive item at risk of automatic closure.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions