Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JetStream CreateOrUpdateConsumerAsync throw NatsJSApiException if FilterSubject contains '.' #448

Open
eddyyuen opened this issue Mar 20, 2024 · 2 comments

Comments

@eddyyuen
Copy link

eddyyuen commented Mar 20, 2024

Observed behavior

When my code like this

var consumer = await _natsJSStream.CreateOrUpdateConsumerAsync(new ConsumerConfig()
 {
     FilterSubject = "a.b.c"
 });

Throw Exception:

NATS.Client.JetStream.NatsJSApiException:“Consumer create request did not match filtered subject from create subject”

If we use this code ,it works

var consumer = await _natsJSStream.CreateOrUpdateConsumerAsync(new ConsumerConfig()
{
    FilterSubject = "a_b_c"
});

Expected behavior

FilterSubject should be able to input any character

Server and client version

nats-server: v2.10.11 (widows amd64)
NATS.Net 2.1.3

Host environment

No response

Steps to reproduce

This throw Exception

 var config = new StreamConfig(name: "test", subjects: new[] {
     "a.b.c"
 });
 _natsJSStream = await _natsJSContext.CreateStreamAsync(config);
var consumer = await _natsJSStream.CreateOrUpdateConsumerAsync(new ConsumerConfig()
 {
     FilterSubject = "a.b.c"
 });

It works:

 var config = new StreamConfig(name: "test", subjects: new[] {
     "a_b_c"
 });
 _natsJSStream = await _natsJSContext.CreateStreamAsync(config);
var consumer = await _natsJSStream.CreateOrUpdateConsumerAsync(new ConsumerConfig()
 {
     FilterSubject = "a_b_c"
 });
@eddyyuen eddyyuen changed the title JetStream CreateOrUpdateConsumerAsync throw NATS.Client.JetStream.NatsJSApiException if ConsumerConfig.FilterSubject contains '.' JetStream CreateOrUpdateConsumerAsync throw NatsJSApiException if FilterSubject contains '.' Mar 20, 2024
@mtmk
Copy link
Collaborator

mtmk commented Mar 20, 2024

Thanks for reporting this @eddyyuen. It looks like a bug where we're mucking up the request subject when consumer name is not provided.

As a workaround, it's fine if you name the consumer:

var consumer = await _natsJSStream.CreateOrUpdateConsumerAsync(new ConsumerConfig("my_consumer")
{
    FilterSubject = "a.b.c"
});

Admittedly there is a little complication due to server support for legacy consumer configurations as consumer implementation evolved and we might not be handling that well to give friendly errors.

Having said all that, I might be missing something here that you don't want to name your consumer for some reason. What sort of consumer are you trying to create?

@eddyyuen
Copy link
Author

Thanks for reporting this @eddyyuen. It looks like a bug where we're mucking up the request subject when consumer name is not provided.

As a workaround, it's fine if you name the consumer:

var consumer = await _natsJSStream.CreateOrUpdateConsumerAsync(new ConsumerConfig("my_consumer")
{
    FilterSubject = "a.b.c"
});

Admittedly there is a little complication due to server support for legacy consumer configurations as consumer implementation evolved and we might not be handling that well to give friendly errors.

Having said all that, I might be missing something here that you don't want to name your consumer for some reason. What sort of consumer are you trying to create?

Thanks! I am new to NATS , and I just forgot to name my consumer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants