Skip to content

Unable to create jetstream consumer if filter_subjects is specified #710

@nickolaj-jepsen

Description

@nickolaj-jepsen

Observed behavior

When trying to use filter_subjects (plural), nats.py throws an error claiming that a consumer can't have both FilterSubject and FilterSubjects

BadRequestError: nats: BadRequestError: code=400 err_code=10136 description='consumer cannot haveboth FilterSubject and FilterSubjects specified'

Expected behavior

I'd expect this not to crash, as i don't provide a specific filter_subject, only filter_subjects

Server and client version

Server: 2.11.6
nats-py: 2.10.0

Host environment

No response

Steps to reproduce

Here's a minimal repro

import nats
import asyncio
from nats.js.api import ConsumerConfig

async def main() -> None:
    connection = await nats.connect("localhost:4222")
    await connection.jetstream().add_stream(
        name="test_stream",
        subjects=["test.>"],
    )

    # Works
    await connection.jetstream().subscribe(
        subject="test.>",
        config=ConsumerConfig(
            filter_subject="test.foo",
        ),
    )

    # Crashes with "nats.js.errors.BadRequestError: nats: BadRequestError: code=400 err_code=10136 description='consumer cannot have both FilterSubject and FilterSubjects specified'"
    await connection.jetstream().subscribe(
        subject="test.>",
        config=ConsumerConfig(
            filter_subjects=["test.foo", "test.bar"],
        ),
    )

asyncio.run(main())

Metadata

Metadata

Assignees

No one assigned

    Labels

    defectSuspected defect such as a bug or regression

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions