{"record":{"id":"d22c1add2207f236","repo":"pathwaycom/pathway","slug":"got-unexpected-keyword-argument-topic-name-pw-i","errorCode":null,"errorMessage":"Got unexpected keyword argument 'topic_name'. pw.io.kafka.read uses 'topic' (the corresponding parameter in pw.io.kafka.write is 'topic_name'). Please rename 'topic_name=' to 'topic='.","messagePattern":"Got unexpected keyword argument 'topic_name'\\. pw\\.io\\.kafka\\.read uses 'topic' \\(the corresponding parameter in pw\\.io\\.kafka\\.write is 'topic_name'\\)\\. Please rename 'topic_name=' to 'topic='\\.","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"python/pathway/io/kafka/__init__.py","lineNumber":317,"sourceCode":"    if (\n        start_from_timestamp_ms is not None\n        and user_offset_reset is not None\n        and user_offset_reset not in _START_FROM_BEGINNING_ALIASES\n    ):\n        warnings.warn(\n            \"'auto.offset.reset' is overridden to 'earliest' whenever \"\n            \"'start_from_timestamp_ms' is set, so the seek can fall back \"\n            f\"to the start of the partition. Your value \"\n            f\"{user_offset_reset!r} is being ignored.\",\n            stacklevel=_stacklevel + 4,\n        )\n\n    # Distinguish \"missing topic\" from \"explicitly empty topic\" — the former\n    # is a user typo (rename to 'topic='), the latter is an invalid value\n    # that Kafka itself would reject with a less actionable error.\n    if topic is None:\n        if \"topic_name\" in kwargs:\n            raise TypeError(\n                \"Got unexpected keyword argument 'topic_name'. \"\n                \"pw.io.kafka.read uses 'topic' (the corresponding parameter \"\n                \"in pw.io.kafka.write is 'topic_name'). Please rename \"\n                \"'topic_name=' to 'topic='.\"\n            )\n        topic_names = kwargs.pop(\"topic_names\", None)\n        if not topic_names:\n            raise ValueError(\"Missing topic name specification\")\n        if isinstance(topic_names, str):\n            warnings.warn(\n                \"'topic_names' is deprecated; please use 'topic' instead.\",\n                DeprecationWarning,\n                stacklevel=_stacklevel + 4,\n            )\n            topic = topic_names\n        elif isinstance(topic_names, (list, tuple)):\n            warnings.warn(\n                \"'topic_names' is deprecated; please use 'topic' instead. \"","sourceCodeStart":299,"sourceCodeEnd":335,"githubUrl":"https://github.com/pathwaycom/pathway/blob/fa2f74a4649b7c5908690cf60137263d8d80de5f/python/pathway/io/kafka/__init__.py#L299-L335","documentation":"pw.io.kafka.read names its topic parameter 'topic', while pw.io.kafka.write names it 'topic_name'. Because **kwargs is part of read's signature (for deprecated aliases), passing topic_name=... would normally be silently ignored; Pathway detects this specific typo and raises TypeError telling you to rename it.","triggerScenarios":"pw.io.kafka.read(rdkafka_settings, topic_name='test-topic') — read() receives no 'topic' positional/keyword and finds 'topic_name' in kwargs.","commonSituations":"Copy-pasting a write() call and changing only the table argument; writing a helper that forwards the same kwargs dict to both read and write; muscle memory from the write API.","solutions":["Rename the keyword: use topic='test-topic' in pw.io.kafka.read.","Keep read and write calls in separate helper functions with their own explicit parameter names rather than sharing one kwargs dict."],"exampleFix":"# before\nt = pw.io.kafka.read(rdkafka_settings, topic_name=\"test-topic\")\n# after\nt = pw.io.kafka.read(rdkafka_settings, topic=\"test-topic\")","handlingStrategy":"validation","validationCode":"def normalize_read_kwargs(kwargs: dict) -> dict:\n    kwargs = dict(kwargs)\n    if \"topic_name\" in kwargs and \"topic\" not in kwargs:\n        kwargs[\"topic\"] = kwargs.pop(\"topic_name\")  # read() uses 'topic'\n    return kwargs\n\nt = pw.io.kafka.read(rdkafka_settings, **normalize_read_kwargs(user_kwargs))","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Mnemonic: read takes 'topic', write takes 'topic_name'.","Keep read and write calls in separate functions with explicit parameter names.","Run a quick grep for topic_name= before every pw.io.kafka.read call in review."],"tags":["kafka","api-misuse","typo","pathway"],"backgroundTag":null,"analyzedSha":"fa2f74a4649b7c5908690cf60137263d8d80de5f","analyzedAt":"2026-08-15T01:48:17.006Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}