{"record":{"id":"8bcc5343faf55d26","repo":"pathwaycom/pathway","slug":"argument-name-has-incorrect-schema","errorCode":null,"errorMessage":"argument {name} has incorrect schema","messagePattern":"argument (.+?) has incorrect schema","errorType":"exception","errorClass":"AssertionError","httpStatus":null,"severity":"error","filePath":"python/pathway/internals/common.py","lineNumber":617,"sourceCode":"                return value\n\n        allow_superset_dict = convert_to_dict(allow_superset)\n        ignore_primary_keys_dict = convert_to_dict(ignore_primary_keys)\n        allow_subtype_dict = convert_to_dict(allow_subtype)\n\n        def check_annotation(name, value):\n            annotation = annotations.get(name, None)\n            if get_origin(annotation) == table.Table and get_args(annotation):\n                try:\n                    assert_table_has_schema(\n                        value,\n                        get_args(annotation)[0],\n                        allow_superset=allow_superset_dict.get(name, True),\n                        ignore_primary_keys=ignore_primary_keys_dict.get(name, True),\n                        allow_subtype=allow_subtype_dict.get(name, True),\n                    )\n                except AssertionError as exc:\n                    raise AssertionError(\n                        f\"argument {name} has incorrect schema\"\n                    ) from exc\n\n        @wraps(f)\n        def wrapper(*args, **kwargs):\n            bound_signature = signature.bind(*args, **kwargs)\n            for name, arg in bound_signature.arguments.items():\n                check_annotation(name, arg)\n\n            return_value = f(*args, **kwargs)\n            check_annotation(\"return\", return_value)\n            return return_value\n\n        return wrapper\n\n    if func is not None:\n        return decorator(func)\n    else:","sourceCodeStart":599,"sourceCodeEnd":635,"githubUrl":"https://github.com/pathwaycom/pathway/blob/fa2f74a4649b7c5908690cf60137263d8d80de5f/python/pathway/internals/common.py#L599-L635","documentation":"Pathway's @table_checked decorator (applied via check_types machinery in common.py) validates function arguments and return values against `pw.Table[Schema]` annotations using assert_table_has_schema. When a table's columns/types do not satisfy the annotated schema (considering allow_superset/ignore_primary_keys/allow_subtype per-argument settings), the underlying AssertionError is re-raised as 'argument <name> has incorrect schema', including name=\"return\" for output mismatches.","triggerScenarios":"Calling a function annotated as def f(t: pw.Table[MySchema]) with a table built from a different schema; returning a table lacking required columns or with mismatched dtypes; passing a table where column types are subtypes when allow_subtype=False for that argument.","commonSituations":"Refactoring shared schemas and forgetting to update one call site; connectors (CSV/kafka) inferring different dtypes than the declared schema; unit tests constructing debug tables with markdown that omit a column.","solutions":["Compare schemas: print the passed table's schema (table.schema) against the annotation's schema and align column names and dtypes.","If extra columns are acceptable, rely on/enable allow_superset for that argument; if primary keys differ, adjust ignore_primary_keys settings in the decorator.","Fix the producer: declare the schema explicitly on the connector (pw.io.csv.read(..., schema=MySchema)) so dtype inference cannot drift.","For name == \"return\", correct the function body so it produces the annotated output schema."],"exampleFix":"# before\nclass MySchema(pw.Schema):\n    key: str\n    value: int\n\ndef transform(t: pw.Table[MySchema]) -> pw.Table[MySchema]:\n    return t.select(key=t.key)  # missing `value` -> 'argument return has incorrect schema'\n\n# after\ndef transform(t: pw.Table[MySchema]) -> pw.Table[MySchema]:\n    return t.select(key=t.key, value=t.value)","handlingStrategy":"validation","validationCode":"from pathway.internals.table import Table\ncols_needed = set(Schema.columns())\ncols_have = set(t.schema.columns())\nmissing = cols_needed - cols_have\nassert not missing, f'missing columns {missing}'","typeGuard":"def table_matches(table, schema_cls) -> bool:\n    try:\n        assert_table_has_schema(table, schema_cls)\n        return True\n    except AssertionError:\n        return False","tryCatchPattern":"try:\n    result = annotated_fn(t)\nexcept AssertionError as e:\n    if 'incorrect schema' in str(e):\n        print(t.schema); raise","preventionTips":["Always pass explicit schema= to connectors instead of relying on inference.","Keep one shared schema module for producer and consumer functions."],"tags":["pathway","schema","type-checking","argument-validation"],"backgroundTag":null,"analyzedSha":"fa2f74a4649b7c5908690cf60137263d8d80de5f","analyzedAt":"2026-08-15T01:48:17.006Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}