pathwaycom/pathway · error · TypeError
Got unexpected keyword argument 'topic_name'. pw.io.kafka.re
Error message
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='.
What it means
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.
Source
Thrown at python/pathway/io/kafka/__init__.py:317
if (
start_from_timestamp_ms is not None
and user_offset_reset is not None
and user_offset_reset not in _START_FROM_BEGINNING_ALIASES
):
warnings.warn(
"'auto.offset.reset' is overridden to 'earliest' whenever "
"'start_from_timestamp_ms' is set, so the seek can fall back "
f"to the start of the partition. Your value "
f"{user_offset_reset!r} is being ignored.",
stacklevel=_stacklevel + 4,
)
# Distinguish "missing topic" from "explicitly empty topic" — the former
# is a user typo (rename to 'topic='), the latter is an invalid value
# that Kafka itself would reject with a less actionable error.
if topic is None:
if "topic_name" in kwargs:
raise TypeError(
"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='."
)
topic_names = kwargs.pop("topic_names", None)
if not topic_names:
raise ValueError("Missing topic name specification")
if isinstance(topic_names, str):
warnings.warn(
"'topic_names' is deprecated; please use 'topic' instead.",
DeprecationWarning,
stacklevel=_stacklevel + 4,
)
topic = topic_names
elif isinstance(topic_names, (list, tuple)):
warnings.warn(
"'topic_names' is deprecated; please use 'topic' instead. "View on GitHub (pinned to fa2f74a464)
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.
Example fix
# before t = pw.io.kafka.read(rdkafka_settings, topic_name="test-topic") # after t = pw.io.kafka.read(rdkafka_settings, topic="test-topic")
Defensive patterns
Strategy: validation
Validate before calling
def normalize_read_kwargs(kwargs: dict) -> dict:
kwargs = dict(kwargs)
if "topic_name" in kwargs and "topic" not in kwargs:
kwargs["topic"] = kwargs.pop("topic_name") # read() uses 'topic'
return kwargs
t = pw.io.kafka.read(rdkafka_settings, **normalize_read_kwargs(user_kwargs)) Prevention
- 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.
When it happens
Trigger: pw.io.kafka.read(rdkafka_settings, topic_name='test-topic') — read() receives no 'topic' positional/keyword and finds 'topic_name' in kwargs.
Common situations: 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.
Related errors
- Missing topic name specification
- 'topic_names' must be a str or a list of str; got {type(topi
- 'topic' must be a non-empty string; got an empty list. Kafka
- 'simple_read' does not accept {forbidden!r}. If you need to
- 'read_only_new=True' together with mode='static' is self-con
AI-assisted analysis of pathwaycom/pathway@fa2f74a464 (2026-08-15).
Data as JSON: /api/errors/d22c1add2207f236.
Report an issue: GitHub.