{"record":{"id":"07cebb8dc4327357","repo":"infiniflow/ragflow","slug":"execution-timeout-must-be-greater-than-0-seconds-07cebb","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/tenki.py","lineNumber":209,"sourceCode":"        arguments: Optional[Dict[str, Any]] = None,\n    ) -> ExecutionResult:\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 Tenki 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        errors = self._tenki_errors()\n\n        args_json = json.dumps(arguments or {}, ensure_ascii=False)\n        script_path, argv = self._prepare_script(sandbox, remote_work_dir, normalized_lang, code, args_json)\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\n        start_time = time.time()\n        try:\n            result = sandbox.exec(*argv, cwd=remote_work_dir, timeout=exec_timeout)\n        except (errors.CommandTimeoutError, errors.PrimitiveTimeoutError) as exc:\n            logger.warning(\"Tenki execution timed out (instance=%s, timeout=%ss)\", instance_id, exec_timeout)\n            raise TimeoutError(f\"Execution timed out after {exec_timeout} seconds\") from exc\n        except (errors.SessionTerminatedError, errors.SessionNotFoundError) as exc:\n            # The sandbox was reclaimed (e.g. max_lifetime) or lost mid-run;\n            # surface it as RuntimeError per the base contract, not an SDK type.\n            raise RuntimeError(f\"Tenki sandbox is no longer available: {exc}\") from exc\n        except Exception as exc:\n            raise RuntimeError(f\"Tenki execution failed: {exc}\") from exc\n        execution_time = time.time() - start_time\n\n        stdout = result.stdout_text\n        stderr = result.stderr_text","sourceCodeStart":191,"sourceCodeEnd":227,"githubUrl":"https://github.com/infiniflow/ragflow/blob/554fb1133ac3861732235ad9c377eb5e0a770665/agent/sandbox/providers/tenki.py#L191-L227","documentation":"Raised by execute_code() when the caller-supplied timeout (or the provider default self.timeout when timeout is None) is zero or negative after int() coercion. It is a pure argument-validation error raised before any sandbox command runs.","triggerScenarios":"Calling execute_code(instance_id, code, timeout=0) or a negative timeout; or a caller-computed timeout that evaluates to <= 0 (e.g. a deadline already passed) while the provider default is overridden.","commonSituations":"Passing a remaining-seconds value derived from an expired deadline, mapping a 0/'unlimited' convention from another API onto this provider (here 0 is invalid — pass None for the configured default), or config files with timeout: 0.","solutions":["Pass a positive integer timeout, or None to use the provider's configured self.timeout.","Clamp computed timeouts: max(1, int(remaining)) before calling execute_code().","If you intended 'no limit', raise the provider config timeout instead of passing 0."],"exampleFix":"# before\nprovider.execute_code(instance_id, code, timeout=max(0, deadline - time.time()))\n\n# after\nprovider.execute_code(instance_id, code, timeout=max(1, int(deadline - time.time())))","handlingStrategy":"validation","validationCode":"timeout = None if timeout in (None,) else int(timeout)\nif timeout is not None and timeout <= 0:\n    raise ValueError(\"timeout must be > 0; pass None for provider default\")","typeGuard":"def is_valid_timeout(t) -> bool:\n    return t is None or (isinstance(t, int) and not isinstance(t, bool) and t > 0)","tryCatchPattern":null,"preventionTips":["Clamp computed deadlines: max(1, int(remaining)).","Use None (not 0) to request the provider-configured default timeout.","Validate caller-supplied timeout at the API boundary before it reaches the sandbox layer."],"tags":["validation","timeout","arguments","tenki"],"backgroundTag":null,"analyzedSha":"554fb1133ac3861732235ad9c377eb5e0a770665","analyzedAt":"2026-08-15T09:20:16.380Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}