infiniflow/ragflow · error · ValueError
Loop condition is incomplete.
Error message
Loop condition is incomplete.
What it means
ValueError from LoopItem.end() while evaluating the parent Loop's termination conditions. Each item in loop_termination_condition must contain both a truthy 'variable' and a truthy 'operator'; an item missing either makes the condition incomplete and the loop cannot decide whether to stop.
Source
Thrown at agent/component/loopitem.py:132
return len(var) == 0
elif operator == "not empty":
return len(var) > 0
elif var is None:
if operator == "empty":
return True
return False
raise Exception(f"Invalid operator: {operator}")
def end(self):
if self._idx == -1:
return True
parent = self.get_parent()
logical_operator = parent._param.logical_operator if hasattr(parent._param, "logical_operator") else "and"
conditions = []
for item in parent._param.loop_termination_condition:
if not item.get("variable") or not item.get("operator"):
raise ValueError("Loop condition is incomplete.")
var = self._canvas.get_variable_value(item["variable"])
operator = item["operator"]
input_mode = item.get("input_mode", "constant")
if input_mode == "variable":
value = self._canvas.get_variable_value(item.get("value", ""))
elif input_mode == "constant":
value = item.get("value", "")
else:
raise ValueError("Invalid input mode.")
conditions.append(self.evaluate_condition(var, operator, value))
should_end = all(conditions) if logical_operator == "and" else any(conditions) if logical_operator == "or" else None
if should_end is None:
raise ValueError("Invalid logical operator,should be 'and' or 'or'.")
if should_end:
self._idx = -1
return TrueView on GitHub (pinned to 554fb1133a)
Solutions
- Complete the condition: choose a variable and an operator for every row in the Loop's termination-condition list.
- Delete unused/placeholder condition rows entirely.
- Validate loop_termination_condition entries all have 'variable' and 'operator' before running the canvas.
Example fix
// before
"loop_termination_condition": [{"variable": "", "operator": "="}]
// after
"loop_termination_condition": [{"variable": "loop_x@counter", "operator": "=", "value": 10}] Defensive patterns
Strategy: validation
Validate before calling
for item in loop_param.loop_termination_condition:
assert item.get('variable') and item.get('operator'), f'incomplete condition row: {item}' Type guard
def condition_complete(item: dict) -> bool:
return bool(item.get('variable')) and bool(item.get('operator')) Try / catch
try:
loop_item.end()
except ValueError as e:
if 'incomplete' in str(e):
# complete or delete the condition row
... Prevention
- Fully configure each termination condition (variable + operator) or delete it.
- Never leave placeholder rows in loop termination conditions.
- Validate conditions at canvas-save time in custom tooling.
When it happens
Trigger: A termination-condition row saved with an empty variable selector or an empty operator; a condition added in the UI but never configured; canvas JSON hand-edited to remove a key.
Common situations: Users add a termination condition then forget to set the variable; duplicated loops where one row lost its binding; templates with placeholder condition rows.
Related errors
- Loop Variable is not complete.
- Invalid operator: {operator}
- Invalid input mode.
- Invalid logical operator,should be 'and' or 'or'.
- [VariableAggregator] group_name can not be empty!
AI-assisted analysis of infiniflow/ragflow@554fb1133a (2026-08-15).
Data as JSON: /api/errors/fa083f6626b4a10e.
Report an issue: GitHub.