pathwaycom/pathway · error · ValueError

Durable consumer name can only be used if JetStream is enabl

Error message

Durable consumer name can only be used if JetStream is enabled

What it means

In Pathway's NATS connector, durable consumer names are a JetStream feature: a durable consumer persists its delivery state inside a JetStream stream. If you pass durable_consumer_name without jetstream_stream_name, the connector has nothing to attach the durable consumer to, so read() raises this ValueError at call time.

Source

Thrown at python/pathway/io/nats/__init__.py:186

    that were added after the last execution. For example, if two new messages arrived since
    the previous run, only those two messages will be read.

    If desired, you can also specify the name of your own durable consumer by setting
    the ``durable_consumer_name`` field. This allows the Pathway Live Data Framework to use your existing durable
    consumer instead of creating a new one automatically.

    >>> table = pw.io.nats.read(
    ...     "nats://127.0.0.1:4222",
    ...     "data",
    ...     format="json",
    ...     schema=InputSchema,
    ...     jetstream_stream_name="your_stream_name",
    ...     durable_consumer_name="your_consumer_name",
    ... )
    """

    if durable_consumer_name is not None and jetstream_stream_name is None:
        raise ValueError(
            "Durable consumer name can only be used if JetStream is enabled"
        )

    data_storage = api.DataStorage(
        storage_type="nats",
        path=uri,
        topic=topic,
        parallel_readers=parallel_readers,
        mode=api.ConnectorMode.STREAMING,
        js_stream_name=jetstream_stream_name,
        durable_consumer_name=durable_consumer_name,
    )
    schema, data_format = construct_schema_and_data_format(
        "binary" if format == "raw" else format,
        schema=schema,
        csv_settings=None,
        json_field_paths=json_field_paths,
    )

View on GitHub (pinned to fa2f74a464)

Solutions

  1. Add the jetstream_stream_name argument naming an existing stream, e.g. jetstream_stream_name="data", durable_consumer_name="my-consumer".
  2. If you do not need durable delivery, remove durable_consumer_name and consume via core NATS.
  3. Verify JetStream is enabled on the NATS server (nats stream info) before using durable consumers.

Example fix

# before
table = pw.io.nats.read("nats://127.0.0.1:4222", "data", format="json", schema=S,
                     durable_consumer_name="my-consumer")

# after
table = pw.io.nats.read("nats://127.0.0.1:4222", "data", format="json", schema=S,
                     jetstream_stream_name="data", durable_consumer_name="my-consumer")
Defensive patterns

Strategy: validation

Validate before calling

if durable_consumer_name is not None:
    assert jetstream_stream_name is not None, (
        "durable_consumer_name requires jetstream_stream_name (JetStream)"
    )

Type guard

from typing import Optional

def is_valid_nats_config(
    durable_consumer_name: Optional[str], jetstream_stream_name: Optional[str]
) -> bool:
    return durable_consumer_name is None or jetstream_stream_name is not None

Try / catch

try:
    table = pw.io.nats.read(uri, topic, format="json", schema=S,
                            durable_consumer_name=consumer)
except ValueError as e:
    if "JetStream" in str(e):
        raise SystemExit("Add jetstream_stream_name or drop durable_consumer_name") from e
    raise

Prevention

When it happens

Trigger: Calling pw.io.nats.read(uri, topic, durable_consumer_name="my-consumer") without a jetstream_stream_name argument. Core NATS (non-JetStream) subscriptions do not support durable consumers at all.

Common situations: Copying durable-consumer configuration from Kafka experience where group ids need no extra setup; enabling at-least-once delivery on a server where JetStream is not enabled; splitting a working JetStream config and dropping the stream-name line.

Related errors


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