{"record":{"id":"2534228f7700b0c2","repo":"microsoft/autogen","slug":"timeout-must-be-greater-than-or-equal-to-1-253422","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/docker/_docker_code_executor.py","lineNumber":183,"sourceCode":"        bind_dir: Optional[Union[Path, str]] = None,\n        auto_remove: bool = True,\n        stop_container: bool = True,\n        device_requests: Optional[List[DeviceRequest]] = None,\n        functions: Sequence[\n            Union[\n                FunctionWithRequirements[Any, A],\n                Callable[..., Any],\n                FunctionWithRequirementsStr,\n            ]\n        ] = [],\n        functions_module: str = \"functions\",\n        extra_volumes: Optional[Dict[str, Dict[str, str]]] = None,\n        extra_hosts: Optional[Dict[str, str]] = None,\n        init_command: Optional[str] = None,\n        delete_tmp_files: bool = False,\n    ):\n        if timeout < 1:\n            raise ValueError(\"Timeout must be greater than or equal to 1.\")\n\n        # Handle working directory logic\n        if work_dir is None:\n            self._work_dir = None\n        else:\n            if isinstance(work_dir, str):\n                work_dir = Path(work_dir)\n            # Emit a deprecation warning if the user is using the current directory as working directory\n            if 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            self._work_dir = work_dir\n            # Create the working directory if it doesn't exist\n            self._work_dir.mkdir(exist_ok=True, parents=True)\n","sourceCodeStart":165,"sourceCodeEnd":201,"githubUrl":"https://github.com/microsoft/autogen/blob/027ecf0a379bcc1d09956d46d12d44a3ad9cee14/python/packages/autogen-ext/src/autogen_ext/code_executors/docker/_docker_code_executor.py#L165-L201","documentation":"Constructor validation in DockerCommandLineCodeExecutor: the `timeout` argument (seconds allowed per code block execution) must be >= 1. Passing 0 or a negative number fails immediately at object construction, before any Docker interaction.","triggerScenarios":"Instantiating DockerCommandLineCodeExecutor(timeout=0) or timeout=-5, or computing timeout from a config value that defaults to 0 (e.g. an unset settings field) and passing it straight through.","commonSituations":"Config-driven constructors where timeout is Optional[int] defaulting to 0/None and 0 is passed instead of a sensible default; copy-pasting from LocalCommandLineCodeExecutor examples that used fractional seconds; CI configs parsing 'timeout' from an empty env var as 0.","solutions":["Pass an explicit positive timeout: timeout=60 (the default)","Fix the upstream config so unset timeouts fall back to a default rather than 0: `timeout = cfg.timeout or 60`","Validate user-supplied config before constructing the executor"],"exampleFix":"# before\nexecutor = DockerCommandLineCodeExecutor(timeout=cfg.timeout)  # cfg.timeout == 0\n\n# after\nexecutor = DockerCommandLineCodeExecutor(timeout=cfg.timeout if cfg.timeout and cfg.timeout >= 1 else 60)","handlingStrategy":"validation","validationCode":"def sane_timeout(cfg) -> int:\n    t = cfg.get(\"timeout\") or 60\n    if not isinstance(t, int) or t < 1:\n        raise ValueError(f\"timeout must be >= 1, got {t!r}\")\n    return t","typeGuard":"def is_valid_timeout(t) -> bool:\n    return isinstance(t, (int, float)) and not isinstance(t, bool) and t >= 1","tryCatchPattern":"null","preventionTips":["Default config values to 60, never 0/None-then-0","Validate user-facing config at load time so constructor validation never fires"],"tags":["docker","validation","constructor","configuration"],"backgroundTag":null,"analyzedSha":"027ecf0a379bcc1d09956d46d12d44a3ad9cee14","analyzedAt":"2026-08-15T03:38:00.719Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}