pathwaycom/pathway · error · ValueError
Topic name must not be empty
Error message
Topic name must not be empty
What it means
Raised by pw.io.pulsar.read when the topic argument is an empty string. An empty topic name is almost always a plumbing bug (unset env var, wrong variable), and letting it through would produce a confusing broker-side error, so Pathway rejects it during graph construction.
Source
Thrown at python/pathway/io/pulsar/__init__.py:358
>>> class EventSchema(pw.Schema):
... event_id: str
... temperature: float
>>> events = pw.io.pulsar.read(
... "pulsar://localhost:6650",
... "measurements",
... format="json",
... schema=EventSchema,
... )
>>> deduplicated = events.groupby(events.event_id).reduce(
... events.event_id,
... temperature=pw.reducers.earliest(events.temperature),
... )
"""
_check_entitlements("pulsar")
_check_tls_settings(tls_settings)
if not topic:
raise ValueError("Topic name must not be empty")
effective_timestamp = resolve_start_from_timestamp_ms(
start_from, start_from_timestamp_ms
)
data_storage = api.DataStorage(
storage_type="pulsar",
path=uri,
topic=topic,
mode=internal_connector_mode(mode),
durable_consumer_name=subscription_name,
start_from_timestamp_ms=effective_timestamp,
tls_settings=tls_settings.settings if tls_settings is not None else None,
pulsar_settings=_construct_pulsar_settings(auth, subscription_type),
)
schema, data_format = construct_schema_and_data_format(
"binary" if format == "raw" else format,
schema=schema,View on GitHub (pinned to fa2f74a464)
Solutions
- Ensure topic is a non-empty string: check the env var name and provide a sensible default or fail fast at config load.
- Centralize validation: raise before calling read if not topic.
- If the topic is dynamic per environment, log the resolved value at startup to catch empty substitutions early.
Example fix
# before
topic = os.environ.get("PULSAR_TOPIC", "")
pw.io.pulsar.read(uri, topic, schema=S)
# after
topic = os.environ.get("PULSAR_TOPIC")
if not topic:
raise RuntimeError("PULSAR_TOPIC must be set to a non-empty topic name")
pw.io.pulsar.read(uri, topic, schema=S) Defensive patterns
Strategy: validation
Validate before calling
topic = os.environ["PULSAR_TOPIC"]
if not topic:
raise RuntimeError("PULSAR_TOPIC is empty")
pw.io.pulsar.read(uri, topic, schema=S) Type guard
def non_empty_topic(topic) -> bool:
return isinstance(topic, str) and bool(topic.strip()) Prevention
- Fail fast on empty env vars at config load, not at connector setup.
- Log resolved topic names at startup.
- Use required env access (os.environ[...]) instead of .get(..., '').
When it happens
Trigger: Calling pw.io.pulsar.read(uri, topic='') or topic=os.environ.get('PULSAR_TOPIC') where the variable is unset/empty; computing the topic name from config that yields an empty string.
Common situations: Environment-driven configuration with a missing or misspelled variable; default topic parameters in shared helper functions that resolve to '' in some deployments; templated configs where the topic placeholder was never filled.
Related errors
- The MQTT topic to read from must not be empty.
- The MQTT topic to publish to must not be empty.
- Failed to install dependencies
- Column {api.TIME_PSEUDOCOLUMN} cannot contain negative times
- Column {api.DIFF_PSEUDOCOLUMN} can only have 1 and -1 values
AI-assisted analysis of pathwaycom/pathway@fa2f74a464 (2026-08-15).
Data as JSON: /api/errors/da95d91cddc2ca66.
Report an issue: GitHub.