infiniflow/ragflow · error · TypeError

The input of List Operations should be an array.

Error message

The input of List Operations should be an array.

What it means

TypeError from the ListOperations component. Its query parameter is resolved through canvas.get_variable_value and must be a Python list; any other type aborts execution before any operation (nth/head/tail/filter/sort/drop_duplicates) runs.

Source

Thrown at agent/component/list_operations.py:57

            self.operations,
            "Support operations",
            ["nth", "head", "tail", "filter", "sort", "drop_duplicates"],
        )

    def get_input_form(self) -> dict[str, dict]:
        return {}


class ListOperations(ComponentBase, ABC):
    component_name = "ListOperations"

    @timeout(int(os.environ.get("COMPONENT_EXEC_TIMEOUT", 10 * 60)))
    def _invoke(self, **kwargs):
        self.input_objects = []
        inputs = getattr(self._param, "query", None)
        self.inputs = self._canvas.get_variable_value(inputs)
        if not isinstance(self.inputs, list):
            raise TypeError("The input of List Operations should be an array.")
        self.set_input_value(inputs, self.inputs)
        if self._param.operations == "nth":
            self._nth()
        elif self._param.operations == "head":
            self._head()
        elif self._param.operations == "tail":
            self._tail()
        elif self._param.operations == "filter":
            self._filter()
        elif self._param.operations == "sort":
            self._sort()
        elif self._param.operations == "drop_duplicates":
            self._drop_duplicates()

    def _coerce_n(self):
        try:
            return int(getattr(self._param, "n", 0))
        except Exception:

View on GitHub (pinned to 554fb1133a)

Solutions

  1. Insert a Code component that does json.loads on the string (or wraps scalars) and outputs a real list.
  2. Point the query selector at an output that is guaranteed to be an array (e.g. a specific list-typed output pin, not the whole output object).
  3. Check for empty/None early: return [] upstream so ListOperations receives a valid (empty) list instead of None.

Example fix

# before
inputs = canvas.get_variable_value("{{str_output}}")  # "[1,2,3]" as text -> TypeError

# after (Code component before ListOperations)
import json
def main(s):
    return json.loads(s) if isinstance(s, str) else s
Defensive patterns

Strategy: type-guard

Validate before calling

inputs = canvas.get_variable_value(query_ref)
assert isinstance(inputs, list), f'ListOperations input is {type(inputs).__name__}, expected list'

Type guard

def is_list(v) -> bool:
    return isinstance(v, list)

Try / catch

try:
    component._invoke()
except TypeError as e:
    if 'should be an array' in str(e):
        # normalize input to list and retry
        ...

Prevention

When it happens

Trigger: Wiring the ListOperations 'query' input to a string, dict, number, or None. Common with a template/LLM output that is a JSON string rather than a parsed array, or a dangling component reference.

Common situations: Feeding a retriever's chunk list through a transform that collapses it to a string; referencing an upstream variable that only populates on some branches, leaving None; passing a dict of outputs instead of one list field.

Related errors


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