{"record":{"id":"99ca78ea59040ad0","repo":"infiniflow/ragflow","slug":"invalid-input-mode","errorCode":null,"errorMessage":"Invalid input mode.","messagePattern":"Invalid input mode\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"agent/component/loopitem.py","lineNumber":142,"sourceCode":"    def end(self):\n        if self._idx == -1:\n            return True\n        parent = self.get_parent()\n        logical_operator = parent._param.logical_operator if hasattr(parent._param, \"logical_operator\") else \"and\"\n        conditions = []\n        for item in parent._param.loop_termination_condition:\n            if not item.get(\"variable\") or not item.get(\"operator\"):\n                raise ValueError(\"Loop condition is incomplete.\")\n            var = self._canvas.get_variable_value(item[\"variable\"])\n            operator = item[\"operator\"]\n            input_mode = item.get(\"input_mode\", \"constant\")\n\n            if input_mode == \"variable\":\n                value = self._canvas.get_variable_value(item.get(\"value\", \"\"))\n            elif input_mode == \"constant\":\n                value = item.get(\"value\", \"\")\n            else:\n                raise ValueError(\"Invalid input mode.\")\n            conditions.append(self.evaluate_condition(var, operator, value))\n        should_end = all(conditions) if logical_operator == \"and\" else any(conditions) if logical_operator == \"or\" else None\n        if should_end is None:\n            raise ValueError(\"Invalid logical operator,should be 'and' or 'or'.\")\n\n        if should_end:\n            self._idx = -1\n            return True\n\n        return False\n\n    def next(self):\n        if self._idx == -1:\n            self._idx = 0\n        else:\n            self._idx += 1\n            if self._idx >= len(self._items):\n                self._idx = -1","sourceCodeStart":124,"sourceCodeEnd":160,"githubUrl":"https://github.com/infiniflow/ragflow/blob/554fb1133ac3861732235ad9c377eb5e0a770665/agent/component/loopitem.py#L124-L160","documentation":"ValueError from LoopItem.end(): when resolving the comparison value for a termination condition, input_mode must be exactly 'variable' or 'constant' (defaulting to 'constant' when absent). Any other string raises immediately.","triggerScenarios":"A loop_termination_condition item whose input_mode is misspelled ('vars', 'Constant ', 'ref') or set to a mode the Loop component does not support. Note: unlike Loop's own variable handling, there is no fallback branch here.","commonSituations":"Hand-written canvas JSON using a mode name from a different component; copy-paste between Loop loop_variables (which tolerate missing modes) and termination conditions (which do not); whitespace/case typos.","solutions":["Set input_mode to exactly 'variable' or 'constant' (lowercase) on every termination-condition row.","Omit input_mode entirely if the value is a constant — the default is 'constant'.","Fix the JSON via the UI dropdown rather than free-text editing."],"exampleFix":"// before\n{\"variable\": \"x\", \"operator\": \">\", \"value\": \"5\", \"input_mode\": \"Value\"}\n\n// after\n{\"variable\": \"x\", \"operator\": \">\", \"value\": \"5\", \"input_mode\": \"constant\"}","handlingStrategy":"validation","validationCode":"for item in loop_param.loop_termination_condition:\n    mode = item.get('input_mode', 'constant')\n    assert mode in {'variable', 'constant'}, f'bad input_mode: {mode!r}'","typeGuard":"def is_valid_input_mode(mode) -> bool:\n    return mode in ('variable', 'constant', None)","tryCatchPattern":"try:\n    loop_item.end()\nexcept ValueError as e:\n    if 'Invalid input mode' in str(e):\n        # set input_mode to 'constant' or 'variable' and re-save\n        ...","preventionTips":["Use exactly lowercase 'variable' or 'constant' (or omit for constant default).","Avoid copying input_mode values between different components' schemas.","Prefer the UI dropdown over hand-editing JSON."],"tags":["loop","input-mode","configuration","agent-canvas"],"backgroundTag":null,"analyzedSha":"554fb1133ac3861732235ad9c377eb5e0a770665","analyzedAt":"2026-08-15T09:20:16.380Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}