{"record":{"id":"31208041794d6b69","repo":"infiniflow/ragflow","slug":"loop-variable-is-not-complete","errorCode":null,"errorMessage":"Loop Variable is not complete.","messagePattern":"Loop Variable is not complete\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"agent/component/loop.py","lineNumber":80,"sourceCode":"            return cls._is_missing_required_field(item.get(\"value\"))\n        if input_mode == \"constant\":\n            return item.get(\"value\") is None\n        return True\n\n    def get_start(self):\n        for cid in self._canvas.components.keys():\n            if self._canvas.get_component(cid)[\"obj\"].component_name.lower() != \"loopitem\":\n                continue\n            if self._canvas.get_component(cid)[\"parent_id\"] == self._id:\n                return cid\n\n    def _invoke(self, **kwargs):\n        if self.check_if_canceled(\"Loop processing\"):\n            return\n\n        for item in self._param.loop_variables:\n            if self._is_incomplete_loop_variable(item):\n                raise ValueError(\"Loop Variable is not complete.\")\n            if item[\"input_mode\"] == \"variable\":\n                self.set_output(item[\"variable\"], self._canvas.get_variable_value(item[\"value\"]))\n            elif item[\"input_mode\"] == \"constant\":\n                self.set_output(item[\"variable\"], item[\"value\"])\n            else:\n                if item[\"type\"] == \"number\":\n                    self.set_output(item[\"variable\"], 0)\n                elif item[\"type\"] == \"string\":\n                    self.set_output(item[\"variable\"], \"\")\n                elif item[\"type\"] == \"boolean\":\n                    self.set_output(item[\"variable\"], False)\n                elif item[\"type\"].startswith(\"object\"):\n                    self.set_output(item[\"variable\"], {})\n                elif item[\"type\"].startswith(\"array\"):\n                    self.set_output(item[\"variable\"], [])\n                else:\n                    self.set_output(item[\"variable\"], \"\")\n","sourceCodeStart":62,"sourceCodeEnd":98,"githubUrl":"https://github.com/infiniflow/ragflow/blob/554fb1133ac3861732235ad9c377eb5e0a770665/agent/component/loop.py#L62-L98","documentation":"ValueError raised at the start of the Loop component's execution. Each entry in loop_variables is checked by _is_incomplete_loop_variable; if an entry lacks required fields (e.g. missing variable name, value, input_mode, or type), the loop refuses to run.","triggerScenarios":"A loop_variables item in the canvas JSON missing keys such as 'variable', 'value', or 'input_mode'; an entry left half-configured in the UI (variable selected but value empty in constant mode); importing a canvas where variables were partially migrated.","commonSituations":"Duplicating a Loop component and deleting a field in the copy; older canvas JSON saved before a required field was introduced; frontend bug saving incomplete rows.","solutions":["Open the Loop component config and complete every loop variable row: name, type, input_mode, and value (or variable selector).","Inspect the canvas JSON (loop_variables array) and fill in or remove entries with missing keys.","After importing a template, re-save the Loop component once so the current schema fills defaults."],"exampleFix":"// before (canvas JSON)\n\"loop_variables\": [{\"variable\": \"counter\", \"input_mode\": \"constant\"}]\n\n// after\n\"loop_variables\": [{\"variable\": \"counter\", \"type\": \"number\", \"input_mode\": \"constant\", \"value\": 0}]","handlingStrategy":"validation","validationCode":"required = {\"variable\", \"input_mode\", \"type\"}\nfor item in loop_param.loop_variables:\n    missing = required - set(item)\n    assert not missing, f'loop variable incomplete, missing: {missing}'","typeGuard":"def loop_variable_complete(item: dict) -> bool:\n    return bool(item.get('variable')) and item.get('input_mode') in {'variable', 'constant'} and 'type' in item","tryCatchPattern":"try:\n    loop._invoke()\nexcept ValueError as e:\n    if 'not complete' in str(e):\n        # re-open config, complete rows, re-save\n        ...","preventionTips":["Complete every loop-variable row (name, type, mode, value) before saving.","Re-save Loop components after importing templates to backfill new required fields.","Audit canvas JSON for partially-filled variable entries after bulk edits."],"tags":["loop","configuration","agent-canvas","validation"],"backgroundTag":null,"analyzedSha":"554fb1133ac3861732235ad9c377eb5e0a770665","analyzedAt":"2026-08-15T09:20:16.380Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}