{"record":{"id":"7453bea5449a2812","repo":"pathwaycom/pathway","slug":"not-all-arguments-marked-as-iterated-returned-from","errorCode":null,"errorMessage":"not all arguments marked as iterated returned from iteration","messagePattern":"not all arguments marked as iterated returned from iteration","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/pathway/internals/operator.py","lineNumber":374,"sourceCode":"        for name, arg in input.items():\n            if isinstance(arg, pw.Table):\n                input_copy[name] = self._copy_input_table(name, arg, unique=False)\n            elif isinstance(arg, iterate_universe):\n                iterated_with_universe_copy[name] = self._copy_input_table(\n                    name, arg.table, unique=True\n                )\n                input[name] = arg.table\n            else:\n                raise TypeError(f\"{name} has to be a Table instead of {type(arg)}\")\n\n        assert all(isinstance(table, pw.Table) for table in input)\n\n        # call iteration logic with copied input and sort result by input order\n        raw_result = self.func_spec.func(**input_copy, **iterated_with_universe_copy)\n        arg_tuple = as_arg_tuple(raw_result)\n        result = arg_tuple.process_input(input)\n        if not iterated_with_universe_copy.is_key_subset_of(result):\n            raise ValueError(\n                \"not all arguments marked as iterated returned from iteration\"\n            )\n        for name, table in result.items():\n            input_table: pw.Table = input[name]\n            assert isinstance(table, pw.Table)\n            input_schema = input_table.schema._dtypes()\n            result_schema = table.schema._dtypes()\n            if input_schema != result_schema:\n                raise ValueError(\n                    f\"output: {result_schema}  of the iterated function does not correspond to the input: {input_schema}\"  # noqa\n                )\n            table._sort_columns_by_other(input_table)\n\n        # designate iterated arguments\n        self.iterated_with_universe = input.intersect_keys(iterated_with_universe_copy)\n        self.iterated = input.intersect_keys(result).subtract_keys(\n            iterated_with_universe_copy\n        )","sourceCodeStart":356,"sourceCodeEnd":392,"githubUrl":"https://github.com/pathwaycom/pathway/blob/fa2f74a4649b7c5908690cf60137263d8d80de5f/python/pathway/internals/operator.py#L356-L392","documentation":"In a @pw.table_transformer used with iteration, arguments marked with pw.iterate_universe must also appear in the transformer's return value: the engine tracks their universes across iteration steps. If the function returns a dict/tuple of tables that omits an argument declared with pw.iterate_universe, this ValueError is raised because the iteration contract is broken.","triggerScenarios":"A transformer like def f(t: pw.Table) -> pw.Table used inside pw.iterate where the original call passed pw.iterate_universe(extra_table) but the returned dict does not include a table under the key 'extra_table'; also returning fewer tables than the iterate_universe-marked inputs.","commonSituations":"Refactoring a transformer to return only a subset of its inputs, renaming returned dict keys so they no longer match argument names, or misunderstanding that iterate_universe args must flow through every iteration step.","solutions":["Return every argument that was passed as pw.iterate_universe: if you call transformer(a=pw.iterate_universe(t1), b=t2), the result must contain key 'a'.","Keep the returned dict keys identical to the argument names of the transformer function.","If the table no longer needs its universe carried through iteration, drop pw.iterate_universe and pass it as a plain argument."],"exampleFix":"# before\n@pw.table_transformer\ndef step(t: pw.Table, carry: pw.Table) -> dict:\n    return {\"t\": t.select(...)}  # 'carry' was iterate_universe, missing\nresult = pw.iterate(step, t=t, carry=pw.iterate_universe(carry))\n\n# after\n@pw.table_transformer\ndef step(t: pw.Table, carry: pw.Table) -> dict:\n    return {\"t\": t.select(...), \"carry\": carry}","handlingStrategy":"validation","validationCode":"import pathway as pw\n\ndef iterate_args_satisfied(func_kwargs, result_dict):\n    required = {n for n, v in func_kwargs.items() if isinstance(v, pw.iterate_universe)}\n    return required <= set(result_dict.keys())","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Return the full input dict pattern: {**inputs, 'result': new_table} and update only what changes.","Keep iterate_universe argument names and returned dict keys identical."],"tags":["pathway","iteration","table-transformer","universe"],"backgroundTag":null,"analyzedSha":"fa2f74a4649b7c5908690cf60137263d8d80de5f","analyzedAt":"2026-08-15T01:48:17.006Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}