{"record":{"id":"0e63c615b3ab5b75","repo":"n8n-io/n8n","slug":"task-timeout-must-be-positive-got-task-timeout","errorCode":null,"errorMessage":"Task timeout must be positive, got {task_timeout}","messagePattern":"Task timeout must be positive, got (.+?)","errorType":"validation","errorClass":"ConfigurationError","httpStatus":null,"severity":"error","filePath":"packages/@n8n/task-runner-python/src/config/task_runner_config.py","lineNumber":82,"sourceCode":"    builtins_deny: set[str]\n    env_deny: bool\n    allow_transitive_imports: bool\n\n    @property\n    def is_auto_shutdown_enabled(self) -> bool:\n        return self.auto_shutdown_timeout > 0\n\n    @classmethod\n    def from_env(cls):\n        grant_token = read_str_env(ENV_GRANT_TOKEN, \"\")\n        if not grant_token:\n            raise ConfigurationError(\n                \"Environment variable N8N_RUNNERS_GRANT_TOKEN is required\"\n            )\n\n        task_timeout = read_int_env(ENV_TASK_TIMEOUT, DEFAULT_TASK_TIMEOUT)\n        if task_timeout <= 0:\n            raise ConfigurationError(\n                f\"Task timeout must be positive, got {task_timeout}\"\n            )\n\n        auto_shutdown_timeout = read_int_env(\n            ENV_AUTO_SHUTDOWN_TIMEOUT, DEFAULT_AUTO_SHUTDOWN_TIMEOUT\n        )\n        if auto_shutdown_timeout < 0:\n            raise ConfigurationError(\n                f\"Auto shutdown timeout must be non-negative, got {auto_shutdown_timeout}\"\n            )\n\n        graceful_shutdown_timeout = read_int_env(\n            ENV_GRACEFUL_SHUTDOWN_TIMEOUT, DEFAULT_SHUTDOWN_TIMEOUT\n        )\n        if graceful_shutdown_timeout <= 0:\n            raise ConfigurationError(\n                f\"Graceful shutdown timeout must be positive, got {graceful_shutdown_timeout}\"\n            )","sourceCodeStart":64,"sourceCodeEnd":100,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/@n8n/task-runner-python/src/config/task_runner_config.py#L64-L100","documentation":"Thrown by TaskRunnerConfig.from_env when the task timeout read from N8N_RUNNERS_TASK_TIMEOUT is zero or negative. The task timeout is the maximum wall-clock seconds a Python code task may run before being killed; a non-positive value would mean immediate or never-ending timeout, neither of which is sensible.","triggerScenarios":"The environment variable ENV_TASK_TIMEOUT is set to 0, a negative number, or left unset but the default DEFAULT_TASK_TIMEOUT was somehow overridden to a non-positive value. The check `if task_timeout <= 0` fires in from_env.","commonSituations":"Setting the timeout to 0 intending 'no timeout' (use a large number instead). Accidentally setting a negative value through a miscalculation in a deployment script. The default constant was changed incorrectly in a fork or custom build.","solutions":["Set N8N_RUNNERS_TASK_TIMEOUT to a positive integer (e.g. 60 for 60 seconds).","If you want a very long timeout, use a large positive value (e.g. 3600) rather than 0 or negative.","Check the environment variable for accidental negative signs or zero values.","Restart the runner after correcting the value."],"exampleFix":"# before\nexport N8N_RUNNERS_TASK_TIMEOUT=0\n# after\nexport N8N_RUNNERS_TASK_TIMEOUT=60","handlingStrategy":"validation","validationCode":"task_timeout = int(os.environ.get('N8N_RUNNERS_TASK_TIMEOUT', '60'))\nif task_timeout <= 0:\n    raise ValueError(f'Task timeout must be positive, got {task_timeout}')","typeGuard":null,"tryCatchPattern":"from config.task_runner_config import ConfigurationError\n\ntry:\n    config = TaskRunnerConfig.from_env()\nexcept ConfigurationError as e:\n    print(f'Fix configuration: {e}')\n    sys.exit(1)","preventionTips":["Always set task timeout to a sensible positive value (e.g. 60-300 seconds).","Validate numeric config in deployment templates.","Don't use 0 to mean 'no timeout' — use a large positive value instead."],"tags":["task-runner","python","configuration","timeout","startup"],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}