{"record":{"id":"8839bcb012b9ceeb","repo":"calesthio/OpenMontage","slug":"environment-variable-env-name-r-not-set-self-i","errorCode":null,"errorMessage":"Environment variable {env_name!r} not set. {self.install_instructions}","messagePattern":"Environment variable (.+?) not set\\. (.+?)","errorType":"exception","errorClass":"DependencyError","httpStatus":null,"severity":"error","filePath":"tools/base_tool.py","lineNumber":317,"sourceCode":"            self.check_dependencies()\n            return ToolStatus.AVAILABLE\n        except DependencyError:\n            return ToolStatus.UNAVAILABLE\n\n    def check_dependencies(self) -> None:\n        \"\"\"Verify all dependencies are installed. Raises DependencyError if not.\"\"\"\n        for dep in self.dependencies:\n            if dep.startswith((\"cmd:\", \"binary:\")):\n                prefix = \"cmd:\" if dep.startswith(\"cmd:\") else \"binary:\"\n                cmd_name = dep[len(prefix):]\n                if shutil.which(cmd_name) is None:\n                    raise DependencyError(\n                        f\"Command {cmd_name!r} not found. {self.install_instructions}\"\n                    )\n            elif dep.startswith(\"env:\"):\n                env_name = dep[4:]\n                if not os.environ.get(env_name):\n                    raise DependencyError(\n                        f\"Environment variable {env_name!r} not set. {self.install_instructions}\"\n                    )\n            elif dep.startswith(\"python:\"):\n                module_name = dep[7:]\n                try:\n                    __import__(module_name)\n                except ImportError:\n                    raise DependencyError(\n                        f\"Python module {module_name!r} not installed. {self.install_instructions}\"\n                    )\n\n    def get_info(self) -> dict[str, Any]:\n        \"\"\"Return full tool contract info for registry/discovery.\"\"\"\n        usage_location = inspect.getfile(self.__class__)\n        return {\n            \"name\": self.name,\n            \"version\": self.version,\n            \"tier\": self.tier.value,","sourceCodeStart":299,"sourceCodeEnd":335,"githubUrl":"https://github.com/calesthio/OpenMontage/blob/95e1c3d0ab93482159818560f6a8c8e866b9139f/tools/base_tool.py#L299-L335","documentation":"Raised by BaseTool.check_dependencies when a dependency declared with the env: prefix names an environment variable that is unset or empty in the current process. The DependencyError includes the variable name and the tool's install_instructions. This is the standard gate for API keys and configuration flags (e.g. env:KLING_API_KEY, env:ELEVENLABS_API_KEY).","triggerScenarios":"Invoking a tool that declares env:SOME_KEY without exporting it; the variable set in the interactive shell but not in the daemon/service/CI process; a .env file that the process never loaded; the variable exported as an empty string, which also fails the check.","commonSituations":"Keys configured per the project's devkey/secret-management workflow but not injected into the child process; cron/systemd/Docker environments missing exports; CI secrets not mapped to the expected variable name.","solutions":["Export the variable in the process that runs the tool (export KLING_API_KEY=... or inject via your secret runner such as devkey run <key> -- <cmd>)","For services/containers, add the variable to the unit file, compose env, or CI secrets mapping — an empty value also fails","Never hardcode the key in code; reference it by name and inject at runtime","Gate with tool.check_available() during preflight so missing keys surface as UNAVAILABLE, not a crash"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"import os\nmissing_env = [d[4:] for d in tool.dependencies if d.startswith(\"env:\") and not os.environ.get(d[4:])]\nif missing_env:\n    raise SystemExit(f\"missing env vars: {missing_env}; inject them via your secret runner\")\n# or: assert tool.check_available() is ToolStatus.AVAILABLE","typeGuard":"def tool_env_vars_set(tool) -> bool:\n    import os\n    return all(os.environ.get(d[4:]) for d in tool.dependencies if d.startswith(\"env:\"))","tryCatchPattern":"from tools.base_tool import DependencyError\ntry:\n    tool.check_dependencies()\nexcept DependencyError as e:\n    if \"Environment variable\" in str(e):\n        raise SystemExit(f\"inject the key via devkey, then retry: {e}\") from e\n    raise","preventionTips":["Inject secrets via the project's secret runner (devkey run <key> -- <cmd>) so child processes inherit them","Empty-string values also fail the check — verify presence, not just definition","Map CI/service secret names to the exact env var names tools declare"],"tags":["dependencies","environment","secrets","configuration"],"backgroundTag":null,"analyzedSha":"95e1c3d0ab93482159818560f6a8c8e866b9139f","analyzedAt":"2026-08-15T06:31:20.014Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}