zeroclaw-labs/zeroclaw · error · anyhow::Error

Docker runtime environment passthrough key must be a variabl

Error message

Docker runtime environment passthrough key must be a variable name

What it means

docker_env_key validates each key from the docker runtime's environment passthrough list. Entries must be plain variable names: an empty key or one containing '=' (a KEY=VALUE pair) is rejected. The list selects which existing environment variables to forward into the container; it does not set values.

Source

Thrown at crates/zeroclaw-config/src/platform/docker.rs:150

                .arg("/workspace");
        }

        process
            .arg(self.config.image.trim())
            .arg("sh")
            .arg("-c")
            .arg(command);

        Ok(process)
    }
}

fn docker_env_key(key: &OsStr) -> Result<&str> {
    let key = key
        .to_str()
        .context("Docker runtime environment passthrough key must be valid UTF-8")?;
    if key.is_empty() || key.contains('=') {
        anyhow::bail!("Docker runtime environment passthrough key must be a variable name");
    }
    Ok(key)
}

impl RuntimeAdapter for DockerRuntime {
    fn name(&self) -> &str {
        "docker"
    }

    fn has_filesystem_access(&self) -> bool {
        self.config.mount_workspace
    }

    fn storage_path(&self) -> PathBuf {
        if self.config.mount_workspace {
            PathBuf::from("/workspace/.zeroclaw")
        } else {
            PathBuf::from("/tmp/.zeroclaw")

View on GitHub (pinned to 88bb9c8533)

Solutions

  1. Keep only variable names in the list: ["HTTP_PROXY", "HTTPS_PROXY"].
  2. Set the actual values in the environment zeroclaw runs in; passthrough forwards them into the container.
  3. If the list is generated from a KEY=VALUE source, split on '=' and keep only the name part, filtering empties.

Example fix

# before
env_passthrough = ["HTTP_PROXY=http://proxy:8080"]

# after
env_passthrough = ["HTTP_PROXY"]   # value comes from the parent environment
Defensive patterns

Strategy: validation

Validate before calling

for key in &env_passthrough_list {
    if key.is_empty() || key.contains('=') {
        return Err(anyhow::anyhow!("env passthrough entries must be names, got {key:?}"));
    }
}

Type guard

fn is_env_var_name(key: &str) -> bool {
    !key.is_empty() && !key.contains('=')
}

Try / catch

match docker_runtime.build_shell_command_inner(cmd) {
    Err(e) if e.to_string().contains("must be a variable name") => {
        // strip '=value' parts from the passthrough list and retry
    }
    other => other,
}

Prevention

When it happens

Trigger: The docker runtime env passthrough configuration containing an entry like "HTTP_PROXY=http://proxy:7890" or "" when build_shell_command_inner iterates the passthrough keys via docker_env_key.

Common situations: Copy-pasting KEY=VALUE lines from docker -e flags or .env files into the passthrough list; programmatic lists built by splitting on commas that leave an empty trailing entry.

Related errors


AI-assisted analysis of zeroclaw-labs/zeroclaw@88bb9c8533 (2026-08-23). Data as JSON: /api/errors/bef5f0b684808f96. Report an issue: GitHub.