pathwaycom/pathway · error · ValueError

Missing topic name specification

Error message

Missing topic name specification

What it means

pw.io.kafka.read needs to know which Kafka topic to subscribe to. When 'topic' is not supplied positionally or by keyword, and no deprecated 'topic_names' alias is found in kwargs, the connector raises ValueError('Missing topic name specification') rather than letting a topic-less consumer silently read nothing.

Source

Thrown at python/pathway/io/kafka/__init__.py:325

            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. "
                "Only the first element of the provided list is used as "
                "the topic name.",
                DeprecationWarning,
                stacklevel=_stacklevel + 4,
            )
            topic = topic_names[0]
        else:
            raise TypeError(

View on GitHub (pinned to fa2f74a464)

Solutions

  1. Pass the topic explicitly: pw.io.kafka.read(rdkafka_settings, topic='test-topic').
  2. Do not embed the topic in rdkafka_settings — Pathway reads it only from the dedicated argument.
  3. The deprecated topic_names=... alias still works (with a DeprecationWarning) but should be migrated to topic=.

Example fix

# before
t = pw.io.kafka.read(rdkafka_settings)
# after
t = pw.io.kafka.read(rdkafka_settings, topic="test-topic")
Defensive patterns

Strategy: validation

Validate before calling

if not topic and not topic_names:
    raise SystemExit("Kafka topic is required; set it via topic=...")

t = pw.io.kafka.read(rdkafka_settings, topic=topic, **({"topic_names": topic_names} if topic_names else {}))

Prevention

When it happens

Trigger: pw.io.kafka.read(rdkafka_settings) with no topic argument; passing the topic inside the rdkafka_settings dict (where it is ignored); passing topic=None explicitly with no alias.

Common situations: Assuming the topic can live inside rdkafka_settings like other librdkafka options; a refactoring that drops the topic argument; passing an empty string topic is a different error — this one is strictly for no specification at all.

Related errors


AI-assisted analysis of pathwaycom/pathway@fa2f74a464 (2026-08-15). Data as JSON: /api/errors/875bfd77eb3cd859. Report an issue: GitHub.