{"record":{"id":"264a2f710a299452","repo":"pathwaycom/pathway","slug":"topic-names-must-be-a-str-or-a-list-of-str-got","errorCode":null,"errorMessage":"'topic_names' must be a str or a list of str; got {type(topic_names).__name__}","messagePattern":"'topic_names' must be a str or a list of str; got (.+?)","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"python/pathway/io/kafka/__init__.py","lineNumber":343,"sourceCode":"            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. \"\n                \"Only the first element of the provided list is used as \"\n                \"the topic name.\",\n                DeprecationWarning,\n                stacklevel=_stacklevel + 4,\n            )\n            topic = topic_names[0]\n        else:\n            raise TypeError(\n                f\"'topic_names' must be a str or a list of str; got \"\n                f\"{type(topic_names).__name__}\"\n            )\n    if isinstance(topic, list):\n        if not topic:\n            raise ValueError(\n                \"'topic' must be a non-empty string; got an empty list. \"\n                \"Kafka does not allow empty topic names.\"\n            )\n        warnings.warn(\n            \"'topic' should be a str, not list. First element will be used.\",\n            DeprecationWarning,\n            stacklevel=_stacklevel + 4,\n        )\n        topic = topic[0]\n\n    if not isinstance(topic, str) or not topic:\n        raise ValueError(","sourceCodeStart":325,"sourceCodeEnd":361,"githubUrl":"https://github.com/pathwaycom/pathway/blob/fa2f74a4649b7c5908690cf60137263d8d80de5f/python/pathway/io/kafka/__init__.py#L325-L361","documentation":"The deprecated 'topic_names' alias in pw.io.kafka.read accepts only a string or a list/tuple of strings (of which just the first element is used, with a warning). Passing any other type — an int, dict, set, None-with-other-keys, etc. — raises TypeError naming the offending type.","triggerScenarios":"pw.io.kafka.read(rdkafka_settings, topic_names=0), topic_names={'t1': 1}, or topic_names=set(['a']). The check happens after the str and (list, tuple) branches, so only non-str non-sequence types reach it.","commonSituations":"Passing a pandas/numpy object or a config structure where a string was expected; reusing the deprecated alias from very old Pathway code with unusual payload types.","solutions":["Migrate to the modern parameter: pw.io.kafka.read(rdkafka_settings, topic='test-topic').","If you must keep topic_names, pass a single string, not a collection or other object.","Note that even a valid list only uses its first element — migrate to topic= to avoid silently dropping topics."],"exampleFix":"# before\nt = pw.io.kafka.read(rdkafka_settings, topic_names=[\"a\", \"b\"])\n# after\nt = pw.io.kafka.read(rdkafka_settings, topic=\"a\")","handlingStrategy":"type-guard","validationCode":"if topic_names is not None and not isinstance(topic_names, (str, list, tuple)):\n    raise SystemExit(f\"topic_names must be str or list of str, got {type(topic_names).__name__}\")","typeGuard":"def valid_topic_names(v) -> bool:\n    return v is None or isinstance(v, (str, list, tuple))","tryCatchPattern":null,"preventionTips":["Migrate off the deprecated topic_names alias — use topic='name'.","Remember list-valued topic_names only ever used the first element."],"tags":["kafka","api-misuse","deprecated","pathway"],"backgroundTag":null,"analyzedSha":"fa2f74a4649b7c5908690cf60137263d8d80de5f","analyzedAt":"2026-08-15T01:48:17.006Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}