{"record":{"id":"30cc3b7aed583f47","repo":"infiniflow/ragflow","slug":"unexpected-error-creating-instance-str-e","errorCode":null,"errorMessage":"Unexpected error creating instance: {str(e)}","messagePattern":"Unexpected error creating instance: (.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"agent/sandbox/providers/aliyun_codeinterpreter.py","lineNumber":196,"sourceCode":"            instance_id = sandbox.sandbox_id\n\n            return SandboxInstance(\n                instance_id=instance_id,\n                provider=\"aliyun_codeinterpreter\",\n                status=\"READY\",\n                metadata={\n                    \"language\": language,\n                    \"region\": self.region,\n                    \"account_id\": self.account_id,\n                    \"template_name\": template_name,\n                    \"created_at\": datetime.now(timezone.utc).isoformat(),\n                },\n            )\n\n        except ServerError as e:\n            raise RuntimeError(f\"Failed to create sandbox instance: {str(e)}\")\n        except Exception as e:\n            raise RuntimeError(f\"Unexpected error creating instance: {str(e)}\")\n\n    def execute_code(self, instance_id: str, code: str, language: str, timeout: int = 10, arguments: Optional[Dict[str, Any]] = None) -> ExecutionResult:\n        \"\"\"\n        Execute code in the Aliyun Code Interpreter instance.\n\n        Args:\n            instance_id: ID of the sandbox instance\n            code: Source code to execute\n            language: Programming language (python, javascript)\n            timeout: Maximum execution time in seconds (max 30)\n            arguments: Optional arguments dict to pass to main() function\n\n        Returns:\n            ExecutionResult containing stdout, stderr, exit_code, and metadata\n\n        Raises:\n            RuntimeError: If execution fails\n            TimeoutError: If execution exceeds timeout","sourceCodeStart":178,"sourceCodeEnd":214,"githubUrl":"https://github.com/infiniflow/ragflow/blob/554fb1133ac3861732235ad9c377eb5e0a770665/agent/sandbox/providers/aliyun_codeinterpreter.py#L178-L214","documentation":"Catch-all wrapping any non-ServerError exception thrown during Aliyun instance creation — typically local problems such as invalid config values, enum/version mismatches in the agentrun SDK, or network-layer errors that surface as plain exceptions rather than ServerError.","triggerScenarios":"create_instance when: an installed agentrun-sdk version changed API surface (e.g. CodeLanguage enum differences), config contains None/invalid fields, DNS/TLS failure raises a requests-style exception, or the default-template branch hits an unhandled code path.","commonSituations":"agentrun-sdk upgraded past 0.0.26 changing enums or method signatures; partially populated config dict; corporate proxy breaking TLS to the Aliyun endpoint; Python version incompatibility with the SDK.","solutions":["Unwrap the embedded str(e) to identify the real exception type and message.","Pin/align the agentrun-sdk version the provider was written against (note the in-code comment about 0.0.26+ enum changes).","Validate all config fields (region, account_id, credentials) are non-empty before initialize.","Test connectivity to the Aliyun endpoint from the host if the cause is network-related."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    instance = provider.create_instance(\"python\")\nexcept RuntimeError as e:\n    logger.exception(\"Aliyun create_instance failed: %s\", e)\n    raise  # the embedded cause string is the diagnostic; do not mask it","preventionTips":["Pin the agentrun-sdk version; the provider documents 0.0.26+ enum drift.","Validate config values are present and correctly typed before initialize.","Keep a smoke-test script that creates and destroys one instance to catch SDK regressions at deploy time."],"tags":["aliyun","provider","sdk-compat","wrapper"],"backgroundTag":null,"analyzedSha":"554fb1133ac3861732235ad9c377eb5e0a770665","analyzedAt":"2026-08-15T09:20:16.380Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}