{"record":{"id":"7fab54aad7f2e532","repo":"pathwaycom/pathway","slug":"durable-consumer-name-can-only-be-used-if-jetstrea","errorCode":null,"errorMessage":"Durable consumer name can only be used if JetStream is enabled","messagePattern":"Durable consumer name can only be used if JetStream is enabled","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/pathway/io/nats/__init__.py","lineNumber":186,"sourceCode":"    that were added after the last execution. For example, if two new messages arrived since\n    the previous run, only those two messages will be read.\n\n    If desired, you can also specify the name of your own durable consumer by setting\n    the ``durable_consumer_name`` field. This allows the Pathway Live Data Framework to use your existing durable\n    consumer instead of creating a new one automatically.\n\n    >>> table = pw.io.nats.read(\n    ...     \"nats://127.0.0.1:4222\",\n    ...     \"data\",\n    ...     format=\"json\",\n    ...     schema=InputSchema,\n    ...     jetstream_stream_name=\"your_stream_name\",\n    ...     durable_consumer_name=\"your_consumer_name\",\n    ... )\n    \"\"\"\n\n    if durable_consumer_name is not None and jetstream_stream_name is None:\n        raise ValueError(\n            \"Durable consumer name can only be used if JetStream is enabled\"\n        )\n\n    data_storage = api.DataStorage(\n        storage_type=\"nats\",\n        path=uri,\n        topic=topic,\n        parallel_readers=parallel_readers,\n        mode=api.ConnectorMode.STREAMING,\n        js_stream_name=jetstream_stream_name,\n        durable_consumer_name=durable_consumer_name,\n    )\n    schema, data_format = construct_schema_and_data_format(\n        \"binary\" if format == \"raw\" else format,\n        schema=schema,\n        csv_settings=None,\n        json_field_paths=json_field_paths,\n    )","sourceCodeStart":168,"sourceCodeEnd":204,"githubUrl":"https://github.com/pathwaycom/pathway/blob/fa2f74a4649b7c5908690cf60137263d8d80de5f/python/pathway/io/nats/__init__.py#L168-L204","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Add the jetstream_stream_name argument naming an existing stream, e.g. jetstream_stream_name=\"data\", durable_consumer_name=\"my-consumer\".","If you do not need durable delivery, remove durable_consumer_name and consume via core NATS.","Verify JetStream is enabled on the NATS server (nats stream info) before using durable consumers."],"exampleFix":"# before\ntable = pw.io.nats.read(\"nats://127.0.0.1:4222\", \"data\", format=\"json\", schema=S,\n                     durable_consumer_name=\"my-consumer\")\n\n# after\ntable = pw.io.nats.read(\"nats://127.0.0.1:4222\", \"data\", format=\"json\", schema=S,\n                     jetstream_stream_name=\"data\", durable_consumer_name=\"my-consumer\")","handlingStrategy":"validation","validationCode":"if durable_consumer_name is not None:\n    assert jetstream_stream_name is not None, (\n        \"durable_consumer_name requires jetstream_stream_name (JetStream)\"\n    )","typeGuard":"from typing import Optional\n\ndef is_valid_nats_config(\n    durable_consumer_name: Optional[str], jetstream_stream_name: Optional[str]\n) -> bool:\n    return durable_consumer_name is None or jetstream_stream_name is not None","tryCatchPattern":"try:\n    table = pw.io.nats.read(uri, topic, format=\"json\", schema=S,\n                            durable_consumer_name=consumer)\nexcept ValueError as e:\n    if \"JetStream\" in str(e):\n        raise SystemExit(\"Add jetstream_stream_name or drop durable_consumer_name\") from e\n    raise","preventionTips":["Treat durable_consumer_name and jetstream_stream_name as a mandatory pair in config.","Verify JetStream is enabled server-side (nats stream ls) before configuring durable consumers.","Keep NATS settings in one config object validated at startup."],"tags":["nats","jetstream","durable-consumer","configuration","pathway"],"backgroundTag":null,"analyzedSha":"fa2f74a4649b7c5908690cf60137263d8d80de5f","analyzedAt":"2026-08-15T01:48:17.006Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}