tinyhumansai/openhuman · error · anyhow::Error

apply_env only works when proxy.scope is 'environment' (curr

Error message

apply_env only works when proxy.scope is 'environment' (current: {:?})

What it means

apply_env only exports proxy variables for configuration whose scope is 'environment'; the persisted proxy has a different scope, so applying it to the process environment would contradict the user's chosen scope.

Source

Thrown at src/openhuman/tools/impl/system/proxy_config.rs:283

        Ok(ToolResult::success(serde_json::to_string_pretty(&json!({
            "message": "Proxy disabled",
            "proxy": Self::proxy_json(&cfg.proxy),
            "environment": Self::env_snapshot(),
        }))?))
    }

    fn handle_apply_env(&self) -> anyhow::Result<ToolResult> {
        let cfg = self.load_config_without_env()?;
        let proxy = cfg.proxy;
        proxy.validate()?;

        if !proxy.enabled {
            anyhow::bail!("Proxy is disabled. Use action 'set' with enabled=true first");
        }

        if proxy.scope != ProxyScope::Environment {
            anyhow::bail!(
                "apply_env only works when proxy.scope is 'environment' (current: {:?})",
                proxy.scope
            );
        }

        proxy.apply_to_process_env();
        set_runtime_proxy_config(proxy.clone());

        Ok(ToolResult::success(serde_json::to_string_pretty(&json!({
            "message": "Proxy environment variables applied",
            "proxy": Self::proxy_json(&proxy),
            "environment": Self::env_snapshot(),
        }))?))
    }

    fn handle_clear_env(&self) -> anyhow::Result<ToolResult> {
        ProxyConfig::clear_process_env();
        Ok(ToolResult::success(serde_json::to_string_pretty(&json!({

View on GitHub (pinned to 7491200858)

Solutions

  1. Set proxy.scope to 'environment' via action 'set' if process-env proxying is intended
  2. Otherwise rely on the scope already configured rather than calling apply_env
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at src/openhuman/tools/impl/system/proxy_config.rs:283 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of tinyhumansai/openhuman@7491200858 (2026-08-17). Data as JSON: /api/errors/3eb6412d39c2515a. Report an issue: GitHub.