{"record":{"id":"9ef3b9313f2e11e6","repo":"microsoft/autogen","slug":"timeout-must-be-greater-than-or-equal-to-1-9ef3b9","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_jupyter/_docker_jupyter.py","lineNumber":166,"sourceCode":"                    print(response.chat_message)\n\n\n        asyncio.run(main())\n\n    \"\"\"\n\n    component_config_schema = DockerJupyterCodeExecutorConfig\n    component_provider_override = \"autogen_ext.code_executors.docker_jupyter.DockerJupyterCodeExecutor\"\n\n    def __init__(\n        self,\n        jupyter_server: Union[JupyterConnectable, JupyterConnectionInfo],\n        kernel_name: str = \"python3\",\n        timeout: int = 60,\n        output_dir: Path | None = None,\n    ):\n        if timeout < 1:\n            raise ValueError(\"Timeout must be greater than or equal to 1.\")\n\n        if isinstance(jupyter_server, JupyterConnectable):\n            self._connection_info = jupyter_server.connection_info\n        elif isinstance(jupyter_server, JupyterConnectionInfo):\n            self._connection_info = jupyter_server\n        else:\n            raise ValueError(\"jupyter_server must be a JupyterConnectable or JupyterConnectionInfo.\")\n\n        self._output_dir = output_dir or getattr(jupyter_server, \"_bind_dir\", None)\n        if not self._output_dir:\n            with tempfile.TemporaryDirectory() as temp_dir:\n                self._output_dir = Path(temp_dir)\n                self._output_dir.mkdir(exist_ok=True)\n\n        self._jupyter_client = JupyterClient(self._connection_info)\n\n        self._kernel_name = kernel_name\n        self._timeout = timeout","sourceCodeStart":148,"sourceCodeEnd":184,"githubUrl":"https://github.com/microsoft/autogen/blob/027ecf0a379bcc1d09956d46d12d44a3ad9cee14/python/packages/autogen-ext/src/autogen_ext/code_executors/docker_jupyter/_docker_jupyter.py#L148-L184","documentation":"Constructor validation in DockerJupyterCodeExecutor: the per-execution timeout (seconds, default 60) must be at least 1. Passing 0 or a negative number is rejected immediately with ValueError before any Docker/Jupyter work begins.","triggerScenarios":"Instantiating DockerJupyterCodeExecutor(jupyter_server=..., timeout=0) or a negative timeout, often from reading timeout out of a config file/env var where the default ended up as 0 or unset.","commonSituations":"Env-var parsing that yields 0 for missing values (int(os.getenv('TIMEOUT', 0))), configs that previously used milliseconds or None, tests constructing the executor with timeout=0 expecting 'no wait'.","solutions":["Pass timeout >= 1 (seconds), e.g. the default 60.","If timeout comes from configuration, coerce/validate it before construction (timeout = max(1, int(timeout))).","Check that you are not passing milliseconds where seconds are expected (60000 is valid but means about 16 hours)."],"exampleFix":"# before\nexecutor = DockerJupyterCodeExecutor(jupyter_server=server, timeout=0)\n\n# after\ntimeout = int(os.getenv(\"EXEC_TIMEOUT\", \"60\")) or 60\nexecutor = DockerJupyterCodeExecutor(jupyter_server=server, timeout=max(1, timeout))","handlingStrategy":"validation","validationCode":"def valid_timeout(t) -> int:\n    t = int(t)\n    if t < 1:\n        raise ValueError(\"timeout must be >= 1 second\")\n    return t","typeGuard":"def is_valid_timeout(t: object) -> bool:\n    return isinstance(t, int) and not isinstance(t, bool) and t >= 1","tryCatchPattern":"try:\n    DockerJupyterCodeExecutor(jupyter_server=server, timeout=t)\nexcept ValueError as e:\n    if \"Timeout\" in str(e):\n        executor = DockerJupyterCodeExecutor(jupyter_server=server, timeout=max(1, int(t)))\n    else:\n        raise","preventionTips":["Centralize timeout parsing with max(1, int(value)) for env/config values.","Never use 0 as an 'unset' sentinel for timeouts."],"tags":["validation","constructor","jupyter","executor"],"backgroundTag":null,"analyzedSha":"027ecf0a379bcc1d09956d46d12d44a3ad9cee14","analyzedAt":"2026-08-15T03:38:00.719Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}