infiniflow/ragflow · error · ContractError

Unsupported expected type

Error message

Unsupported expected type: {expected_type}

What it means

Error "Unsupported expected type: {expected_type}" thrown in infiniflow/ragflow.

Solutions

  1. Use one of the supported expected types in the CodeExec contract.
  2. Check the contract schema for the list of allowed type names.

Example fix

outputs = [{'name': 'result', 'type': 'Array'}]  # supported type

When it happens

Trigger: Thrown at agent/tools/code_exec.py:144 when the library encounters an invalid state.

Common situations: The CodeExec contract specifies a type outside the supported set (e.g. a typo or a language-specific type); using a supported type name prevents this error.


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

Appendix: source

Thrown at agent/tools/code_exec.py:144


def _normalize_expected_type(expected_type: str) -> str:
    etype = expected_type.strip()
    low = etype.lower()
    simple_types = {
        "string": "String",
        "number": "Number",
        "boolean": "Boolean",
        "object": "Object",
        "null": "Null",
        "any": "Any",
    }
    if low in simple_types:
        return simple_types[low]
    if low.startswith("array<") and low.endswith(">"):
        inner = etype[etype.find("<") + 1 : -1].strip()
        if not inner:
            raise ContractError(f"Unsupported expected type: {expected_type}")
        return f"Array<{_normalize_expected_type(inner)}>"
    return etype


def _validate_expected_type(expected_type: str, value, path: str = "") -> None:
    etype = _normalize_expected_type(expected_type)
    if not etype or etype.lower() == "any":
        return

    value = normalize_output_value(value)

    if etype.startswith("Array<") and etype.endswith(">"):
        inner_type = etype[6:-1].strip()
        if not isinstance(value, list):
            raise ContractError(f"CodeExec contract mismatch at {path or 'value'}: expected type {etype}, got {infer_actual_type(value)}")
        for index, item in enumerate(value):
            child_path = f"{path}[{index}]" if path else f"[{index}]"
            _validate_expected_type(inner_type, item, child_path)

View on GitHub (pinned to 554fb1133a)