infiniflow/ragflow · error · RuntimeError

Unexpected error creating instance: {str(e)}

Error message

Unexpected error creating instance: {str(e)}

What it means

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.

Source

Thrown at agent/sandbox/providers/aliyun_codeinterpreter.py:196

            instance_id = sandbox.sandbox_id

            return SandboxInstance(
                instance_id=instance_id,
                provider="aliyun_codeinterpreter",
                status="READY",
                metadata={
                    "language": language,
                    "region": self.region,
                    "account_id": self.account_id,
                    "template_name": template_name,
                    "created_at": datetime.now(timezone.utc).isoformat(),
                },
            )

        except ServerError as e:
            raise RuntimeError(f"Failed to create sandbox instance: {str(e)}")
        except Exception as e:
            raise RuntimeError(f"Unexpected error creating instance: {str(e)}")

    def execute_code(self, instance_id: str, code: str, language: str, timeout: int = 10, arguments: Optional[Dict[str, Any]] = None) -> ExecutionResult:
        """
        Execute code in the Aliyun Code Interpreter instance.

        Args:
            instance_id: ID of the sandbox instance
            code: Source code to execute
            language: Programming language (python, javascript)
            timeout: Maximum execution time in seconds (max 30)
            arguments: Optional arguments dict to pass to main() function

        Returns:
            ExecutionResult containing stdout, stderr, exit_code, and metadata

        Raises:
            RuntimeError: If execution fails
            TimeoutError: If execution exceeds timeout

View on GitHub (pinned to 554fb1133a)

Solutions

  1. Unwrap the embedded str(e) to identify the real exception type and message.
  2. Pin/align the agentrun-sdk version the provider was written against (note the in-code comment about 0.0.26+ enum changes).
  3. Validate all config fields (region, account_id, credentials) are non-empty before initialize.
  4. Test connectivity to the Aliyun endpoint from the host if the cause is network-related.
Defensive patterns

Strategy: try-catch

Try / catch

try:
    instance = provider.create_instance("python")
except RuntimeError as e:
    logger.exception("Aliyun create_instance failed: %s", e)
    raise  # the embedded cause string is the diagnostic; do not mask it

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of infiniflow/ragflow@554fb1133a (2026-08-15). Data as JSON: /api/errors/30cc3b7aed583f47. Report an issue: GitHub.