{"record":{"id":"51bed7d47cdd1961","repo":"microsoft/autogen","slug":"timeout-must-be-greater-than-or-equal-to-1-51bed7","errorCode":null,"errorMessage":"Timeout must be greater than or equal to 1.","messagePattern":"Timeout must be greater than or equal to 1\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/packages/autogen-ext/src/autogen_ext/code_executors/local/__init__.py","lineNumber":172,"sourceCode":"                Callable[..., Any],\n                FunctionWithRequirementsStr,\n            ]\n        ] = [],\n        functions_module: str = \"functions\",\n        cleanup_temp_files: bool = True,\n        virtual_env_context: Optional[SimpleNamespace] = None,\n    ):\n        # Issue warning about using LocalCommandLineCodeExecutor\n        warnings.warn(\n            \"Using LocalCommandLineCodeExecutor may execute code on the local machine which can be unsafe. \"\n            \"For security, it is recommended to use DockerCommandLineCodeExecutor instead. \"\n            \"To install Docker, visit: https://docs.docker.com/get-docker/\",\n            UserWarning,\n            stacklevel=2,\n        )\n\n        if timeout < 1:\n            raise ValueError(\"Timeout must be greater than or equal to 1.\")\n        self._timeout = timeout\n\n        self._work_dir: Optional[Path] = None\n        if work_dir is not None:\n            # Check if user provided work_dir is the current directory and warn if so.\n            if Path(work_dir).resolve() == Path.cwd().resolve():\n                warnings.warn(\n                    \"Using the current directory as work_dir is deprecated.\",\n                    DeprecationWarning,\n                    stacklevel=2,\n                )\n            if isinstance(work_dir, str):\n                self._work_dir = Path(work_dir)\n            else:\n                self._work_dir = work_dir\n            self._work_dir.mkdir(exist_ok=True)\n\n        self._functions = functions","sourceCodeStart":154,"sourceCodeEnd":190,"githubUrl":"https://github.com/microsoft/autogen/blob/027ecf0a379bcc1d09956d46d12d44a3ad9cee14/python/packages/autogen-ext/src/autogen_ext/code_executors/local/__init__.py#L154-L190","documentation":"Constructor validation in LocalCommandLineCodeExecutor: timeout (seconds per command, default 60) must be >= 1. Zero/negative raises ValueError right after the safety UserWarning about executing code locally.","triggerScenarios":"LocalCommandLineCodeExecutor(timeout=0) or a negative timeout, usually from config/env parsing that yields 0 when unset or from millisecond-vs-second confusion.","commonSituations":"Defaults like int(os.getenv('LOCAL_TIMEOUT', 0)) when the var is unset, passing 60_000 (milliseconds) which silently works but means about 16 hours, computed timeouts underflowing to 0, tests with timeout=0 expecting immediate abort.","solutions":["Pass timeout >= 1 second (e.g. default 60).","Clamp externally sourced values: timeout = max(1, int(raw)).","If you actually want short waits, use a small positive value like 5, not 0."],"exampleFix":"# before\nexecutor = LocalCommandLineCodeExecutor(timeout=0)\n\n# after\nexecutor = LocalCommandLineCodeExecutor(timeout=60)","handlingStrategy":"validation","validationCode":"timeout = int(os.getenv(\"LOCAL_EXEC_TIMEOUT\", \"60\")) or 60\ntimeout = max(1, timeout)","typeGuard":"def is_valid_timeout(t: object) -> bool:\n    return isinstance(t, int) and not isinstance(t, bool) and t >= 1","tryCatchPattern":"try:\n    LocalCommandLineCodeExecutor(timeout=t)\nexcept ValueError as e:\n    if \"Timeout\" in str(e):\n        executor = LocalCommandLineCodeExecutor(timeout=max(1, int(t)))\n    else:\n        raise","preventionTips":["Clamp config-sourced timeouts with max(1, ...).","Remember units are seconds; document it next to config keys."],"tags":["validation","constructor","local-executor"],"backgroundTag":null,"analyzedSha":"027ecf0a379bcc1d09956d46d12d44a3ad9cee14","analyzedAt":"2026-08-15T03:38:00.719Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}