{"record":{"id":"3eb6412d39c2515a","repo":"tinyhumansai/openhuman","slug":"apply-env-only-works-when-proxy-scope-is-environm","errorCode":null,"errorMessage":"apply_env only works when proxy.scope is 'environment' (current: {:?})","messagePattern":"apply_env only works when proxy\\.scope is 'environment' \\(current: (.+?)\\)","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"src/openhuman/tools/impl/system/proxy_config.rs","lineNumber":283,"sourceCode":"\n        Ok(ToolResult::success(serde_json::to_string_pretty(&json!({\n            \"message\": \"Proxy disabled\",\n            \"proxy\": Self::proxy_json(&cfg.proxy),\n            \"environment\": Self::env_snapshot(),\n        }))?))\n    }\n\n    fn handle_apply_env(&self) -> anyhow::Result<ToolResult> {\n        let cfg = self.load_config_without_env()?;\n        let proxy = cfg.proxy;\n        proxy.validate()?;\n\n        if !proxy.enabled {\n            anyhow::bail!(\"Proxy is disabled. Use action 'set' with enabled=true first\");\n        }\n\n        if proxy.scope != ProxyScope::Environment {\n            anyhow::bail!(\n                \"apply_env only works when proxy.scope is 'environment' (current: {:?})\",\n                proxy.scope\n            );\n        }\n\n        proxy.apply_to_process_env();\n        set_runtime_proxy_config(proxy.clone());\n\n        Ok(ToolResult::success(serde_json::to_string_pretty(&json!({\n            \"message\": \"Proxy environment variables applied\",\n            \"proxy\": Self::proxy_json(&proxy),\n            \"environment\": Self::env_snapshot(),\n        }))?))\n    }\n\n    fn handle_clear_env(&self) -> anyhow::Result<ToolResult> {\n        ProxyConfig::clear_process_env();\n        Ok(ToolResult::success(serde_json::to_string_pretty(&json!({","sourceCodeStart":265,"sourceCodeEnd":301,"githubUrl":"https://github.com/tinyhumansai/openhuman/blob/749120085864ce16e0f273c7b86fac7740b39c5b/src/openhuman/tools/impl/system/proxy_config.rs#L265-L301","documentation":"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.","triggerScenarios":"Thrown at src/openhuman/tools/impl/system/proxy_config.rs:283 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Set proxy.scope to 'environment' via action 'set' if process-env proxying is intended","Otherwise rely on the scope already configured rather than calling apply_env"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"749120085864ce16e0f273c7b86fac7740b39c5b","analyzedAt":"2026-08-17T21:21:45.363Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}