infiniflow/ragflow · error · RuntimeError

Provider not initialized. Call initialize() first.

Error message

Provider not initialized. Call initialize() first.

What it means

Raised by SelfManagedProvider.create_instance() when the provider's initialize() has not completed, i.e. self._initialized is False. SelfManagedProvider delegates execution to a remote sandbox service reached over HTTP; create_instance only mints a logical UUID for tracking, but it still requires a successful initialize() (endpoint configured and reachable) first. RuntimeError, thrown before any instance is created.

Source

Thrown at agent/sandbox/providers/self_managed.py:94

    def create_instance(self, template: str = "python") -> SandboxInstance:
        """
        Create a new sandbox instance.

        Note: For self-managed provider, instances are managed internally
        by the executor_manager's container pool. This method returns
        a logical instance handle.

        Args:
            template: Programming language (python, nodejs)

        Returns:
            SandboxInstance object

        Raises:
            RuntimeError: If instance creation fails
        """
        if not self._initialized:
            raise RuntimeError("Provider not initialized. Call initialize() first.")

        # Normalize language
        language = self._normalize_language(template)

        # The executor_manager manages instances internally via container pool
        # We create a logical instance ID for tracking
        instance_id = str(uuid.uuid4())

        return SandboxInstance(
            instance_id=instance_id,
            provider="self_managed",
            status="running",
            metadata={
                "language": language,
                "endpoint": self.endpoint,
                "pool_size": self.pool_size,
            },
        )

View on GitHub (pinned to 554fb1133a)

Solutions

  1. Call provider.initialize(config) with a valid config (endpoint, timeout, etc.) and only call create_instance() after it returns True.
  2. Check the result/exceptions of initialize() and abort the workflow on failure instead of continuing.
  3. Initialize once at provider construction or session start and reuse the instance; do not re-create the provider per request without init.
  4. If initialize() fails, inspect its error (endpoint URL, connectivity) before retrying.

Example fix

# before
provider = SelfManagedProvider()
instance = provider.create_instance("python")

# after
provider = SelfManagedProvider()
if not provider.initialize(config):
    raise RuntimeError("sandbox provider failed to initialize")
instance = provider.create_instance("python")
Defensive patterns

Strategy: validation

Validate before calling

provider = SelfManagedProvider()
assert provider.initialize(config), "sandbox init failed"
# only now:
instance = provider.create_instance("python")

Type guard

def is_ready(provider) -> bool:
    """True after a successful initialize()."""
    return bool(getattr(provider, "_initialized", False))

Try / catch

try:
    instance = provider.create_instance("python")
except RuntimeError as e:
    if "not initialized" in str(e):
        provider.initialize(config)
        instance = provider.create_instance("python")
    else:
        raise

Prevention

When it happens

Trigger: Constructing SelfManagedProvider() and calling create_instance('python') without calling initialize(config); initialize() previously raised (bad endpoint/config) leaving _initialized False, then the caller ignores the failure and proceeds; using a new provider object after a restart while the code path assumes prior init.

Common situations: Missing initialize() call in a custom integration or test; an exception during initialize() being swallowed by a broad try/except that then continues to create_instance(); lifecycle code that creates the provider lazily but calls execute paths in the wrong order.

Related errors


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