nats-io / natscli

The NATS Command Line Interface
Apache License 2.0
497 stars 99 forks source link

Error editing a consumer from singular filter subject to multiple filter subjects #918

Closed dpalat closed 10 months ago

dpalat commented 1 year ago

Observed behavior

There is an issue in the cli when I'm trying to edit a jetstream consumer from single subject filter to multiple subject filters the cli give me the erro "nats: error: consumer with multiple subject filters cannot use subject based API (10137)"

image

Expected behavior

Apply the change well

Server and client version

cli version: 0.1.1 nats version: 2.10.3 nack version: natsio/jetstream-controller:0.13.0 yml version: jetstream.nats.io/v1beta2

Host environment

No response

Steps to reproduce

create a jetstream consumer with a single filter and then try to pass a multiple subject filters:

STREAM nats stream add TEST01 --subjects="TEST01...." --ack --max-msgs=-1 --max-bytes=-1 --max-age=24h --max-msg-size=262144 --max-msgs-per-subject=-1 --storage=memory --retention=interest --discard=new --dupe-window="2m0s" --no-allow-rollup --no-deny-delete --no-deny-purge --replicas=1

NEW CONSUMER nats consumer add TEST01 consumer01 --filter="TEST01.default_one...*" --pull --deliver=all --ack=explicit --replay=instant --max-deliver=-1 --max-pending=1000 --backoff=none --no-headers-only

EDIT CONSUMER nats consumer edit TEST01 consumer01 --filter="TEST01.default_one..." --filter="TEST01.default_two..."

dpalat commented 1 year ago

If you came here trying to look a workaround I need to tell you yes!, there is a one that works perfect!, I read the workaround from Maurice in the following screenshot from nats slack channel

image

ripienaar commented 10 months ago

Fixed in next release

[rip@p1-lon]% bin/nats c edit X C1 --filter js.in.x.1 --filter js.in.x.2
Differences (-old +new):
  api.ConsumerConfig{
        ... // 6 identical fields
        Durable:        "C1",
        Name:           "C1",
-       FilterSubject:  "js.in.x",
+       FilterSubject:  "",
-       FilterSubjects: []string(Inverse(Sort, []string(nil))),
+       FilterSubjects: []string(Inverse(Sort, []string{"js.in.x.1", "js.in.x.2"})),
        FlowControl:    false,
        Heartbeat:      s"0s",
        ... // 18 identical fields
  }