infiniflow/ragflow · error · RuntimeError

Unsupported artifact type: {relative_path}

Error message

Unsupported artifact type: {relative_path}

What it means

Raised during artifact collection when a file's lowercase extension is not in ALLOWED_ARTIFACT_EXTENSIONS. Only a whitelist of file types may be returned as artifacts; anything else (executables, unknown or missing extensions) aborts collection.

Source

Thrown at agent/sandbox/providers/ucloud_agent_sandbox.py:436

        try:
            entries = sandbox.files.list(current_dir, depth=1, request_timeout=self.timeout)
        except sdk.FileNotFoundException:
            return
        for entry in sorted(entries, key=lambda item: item.path):
            name = posixpath.basename(entry.path)
            relative_path = posixpath.join(relative_dir, name) if relative_dir else name
            if entry.symlink_target is not None:
                raise RuntimeError(f"Artifact symlinks are not allowed: {relative_path}")
            if entry.type == sdk.FileType.DIR:
                self._collect_artifacts_recursive(sandbox, entry.path, relative_path, artifacts, depth + 1)
                continue
            if len(artifacts) >= self.max_artifacts:
                raise RuntimeError(f"UCloud Agent Sandbox execution produced more than {self.max_artifacts} artifacts.")
            if entry.size > self.max_artifact_bytes:
                raise RuntimeError(f"Artifact exceeds {self.max_artifact_bytes} bytes: {relative_path}")
            extension = os.path.splitext(name)[1].lower()
            if extension not in ALLOWED_ARTIFACT_EXTENSIONS:
                raise RuntimeError(f"Unsupported artifact type: {relative_path}")
            content = bytes(sandbox.files.read(entry.path, format="bytes", request_timeout=self.timeout))
            artifacts.append(
                {
                    "name": relative_path,
                    "content_b64": base64.b64encode(content).decode("ascii"),
                    "mime_type": mimetypes.guess_type(name)[0] or "application/octet-stream",
                    "size": entry.size,
                }
            )

    def _safe_kill(self, sandbox) -> None:
        """Best-effort terminate a remote sandbox during cleanup."""
        try:
            sandbox.kill(request_timeout=self.timeout)
        except Exception as exc:  # noqa: BLE001 - cleanup is deliberately best-effort
            logger.warning("Failed to kill UCloud Agent Sandbox %s: %s", sandbox.sandbox_id, exc)

    @staticmethod

View on GitHub (pinned to 554fb1133a)

Solutions

  1. Emit artifacts in allowed common formats (e.g. .txt/.json/.png/.csv — check ALLOWED_ARTIFACT_EXTENSIONS in the module) and rename outputs accordingly.
  2. Keep non-artifact intermediate files outside the artifacts directory.
  3. If a type is legitimately needed, extend ALLOWED_ARTIFACT_EXTENSIONS in a patch after reviewing the security implications.
  4. Catch the RuntimeError to surface 'unsupported artifact type' clearly to the agent/user.

Example fix

# before
open("artifacts/run.sh", "w").write(script)  # .sh not allowlisted -> RuntimeError

# after
open("artifacts/run_script.txt", "w").write(script)
Defensive patterns

Strategy: validation

Validate before calling

from agent.sandbox.providers.ucloud_agent_sandbox import ALLOWED_ARTIFACT_EXTENSIONS
import os

outputs = [f for f in candidate_files]
bad = [f for f in outputs if os.path.splitext(f)[1].lower() not in ALLOWED_ARTIFACT_EXTENSIONS]
if bad:
    raise ValueError(f"artifact extensions not allowed: {bad}")

Type guard

def has_allowed_artifact_extensions(filenames: list[str], allowed: set[str]) -> bool:
    return all(os.path.splitext(f)[1].lower() in allowed for f in filenames)

Try / catch

try:
    result = provider.execute(inst, code)
except RuntimeError as e:
    if "Unsupported artifact type" in str(e):
        result = provider.execute(inst, rename_artifacts_to_allowed(code))
    else:
        raise

Prevention

When it happens

Trigger: Executed code writing files with extensions outside the allowlist — e.g. .exe, .sh, .pyc, .so, or extensionless files — into the artifacts directory.

Common situations: Build-style user code emitting binaries or scripts; tools writing dotfiles/extensionless temp files; LLM-generated code saving output with a creative filename the allowlist never anticipated.

Related errors


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