{"record":{"id":"c79ba5c72b51df99","repo":"infiniflow/ragflow","slug":"execution-timeout-must-be-greater-than-0-seconds-c79ba5","errorCode":null,"errorMessage":"Execution timeout must be greater than 0 seconds, got {requested_timeout}.","messagePattern":"Execution timeout must be greater than 0 seconds, got (.+?)\\.","errorType":"validation","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"agent/sandbox/providers/ucloud_agent_sandbox.py","lineNumber":192,"sourceCode":"            arguments: Values passed to the user-defined main function.\n\n        Returns:\n            Captured output, structured result metadata, and allowed artifacts.\n        \"\"\"\n        if not self._initialized:\n            raise RuntimeError(\"Provider not initialized. Call initialize() first.\")\n        if instance_id not in self._instances:\n            raise RuntimeError(f\"Unknown UCloud Agent Sandbox instance: {instance_id}\")\n\n        normalized_lang = self._normalize_language(language)\n        instance = self._instances[instance_id]\n        sandbox = instance[\"sandbox\"]\n        remote_work_dir: str = instance[\"remote_work_dir\"]\n        script_path, executable = self._prepare_script(sandbox, remote_work_dir, normalized_lang, code, arguments or {})\n\n        requested_timeout = self.timeout if timeout is None else int(timeout)\n        if requested_timeout <= 0:\n            raise RuntimeError(f\"Execution timeout must be greater than 0 seconds, got {requested_timeout}.\")\n        exec_timeout = min(requested_timeout, self.timeout)\n        sdk = _get_ucloud_sandbox_module()\n\n        start_time = time.time()\n        try:\n            sandbox.set_timeout(max(self.sandbox_timeout, exec_timeout + 30), request_timeout=self.timeout)\n            result = sandbox.commands.run(\n                f\"{executable} {shlex.quote(script_path)}\",\n                cwd=remote_work_dir,\n                timeout=exec_timeout,\n                request_timeout=max(self.timeout, exec_timeout),\n            )\n        except sdk.CommandExitException as exc:\n            result = exc\n        except sdk.TimeoutException as exc:\n            raise TimeoutError(f\"Execution timed out after {exec_timeout} seconds\") from exc\n        except Exception as exc:\n            raise RuntimeError(f\"UCloud Agent Sandbox execution failed: {exc}\") from exc","sourceCodeStart":174,"sourceCodeEnd":210,"githubUrl":"https://github.com/infiniflow/ragflow/blob/554fb1133ac3861732235ad9c377eb5e0a770665/agent/sandbox/providers/ucloud_agent_sandbox.py#L174-L210","documentation":"Raised by the provider's execute path when the resolved execution timeout is zero or negative. `requested_timeout` defaults to the configured `self.timeout` (30) when the caller passes timeout=None; an explicit int(timeout) <= 0 is rejected before any code runs.","triggerScenarios":"Calling execute with timeout=0, a negative timeout, or a string like '-1' that int() accepts; or configuring the provider with timeout<=0 so the default itself is invalid.","commonSituations":"Agents computing timeout from a remaining-budget value that hits 0 under deadline pressure; config templates that set timeout: 0 intending 'no wait'; passing timeout as float seconds smaller than 1 (int(0.5) == 0).","solutions":["Pass a positive timeout (>=1) or omit it to use the configured default of 30s.","Clamp computed deadlines: `timeout=max(1, int(remaining))`.","Fix provider config if `timeout` itself is <= 0.","Validate before calling execute (see defense below) to fail with your own clearer error."],"exampleFix":"# before\nprovider.execute(inst, code, timeout=max(0, int(remaining)))  # remaining=0 -> RuntimeError\n\n# after\nprovider.execute(inst, code, timeout=max(1, int(remaining)))","handlingStrategy":"validation","validationCode":"resolved = provider.timeout if timeout is None else int(timeout)\nif resolved <= 0:\n    raise ValueError(f\"timeout must be > 0, got {resolved}\")\nresult = provider.execute(instance_id, code, timeout=resolved)","typeGuard":"def is_positive_timeout(timeout) -> bool:\n    try:\n        return int(timeout) > 0\n    except (TypeError, ValueError):\n        return False","tryCatchPattern":"try:\n    result = provider.execute(instance_id, code, timeout=timeout)\nexcept RuntimeError as e:\n    if \"must be greater than 0\" in str(e):\n        result = provider.execute(instance_id, code)  # fall back to configured default\n    else:\n        raise","preventionTips":["Clamp deadline-derived timeouts: max(1, int(remaining)).","Remember int(0.5) == 0 — floats below 1 are rejected too.","Validate timeout at the agent layer so users see a clear message instead of a provider RuntimeError."],"tags":["validation","timeout","ucloud","sandbox","precondition"],"backgroundTag":null,"analyzedSha":"554fb1133ac3861732235ad9c377eb5e0a770665","analyzedAt":"2026-08-15T09:20:16.380Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}