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

JetStreamContext ConsumerInfo and AddConsumer allow user to pass options but ignore them #1104

Open
TomasVojacek opened this issue Oct 11, 2022 · 2 comments
Assignees
Labels
bug Confirmed reproducible bug

Comments

@TomasVojacek
Copy link

Defect

Signature of ConsumerInfo and AddConsumer allow pass JSOpt but ignore most of them only context or timeout is used.

nats.go/jsm.go

Line 439 in 543e628

o, cancel, err := getJSContextOpts(js.opts, opts...)

nats.go/jsm.go

Line 446 in 543e628

return js.getConsumerInfoContext(o.ctx, stream, consumer)

Rest of options like domain is ignored.

Versions of nats.go and the nats-server if one was involved:

nats.go 1.16 and 1.17

OS/Container environment:

N/A

Steps or code to reproduce the issue:

create jetstream my_stream_on_domain on domain my_domain
and consumer "any_consumer_name"
call:

	consumer, err := js.ConsumerInfo("my_stream_on_domain", "any_consumer_name", nats.Domain("my_domain"))
	if err != nil {
                if errors.Is(err, nats.ErrStreamNotFound) {
                        t.fail()
                 }
	}

Expected result:

got consumer info and err is nil

Actual result:

got error nats.ErrStreamNotFound

@TomasVojacek TomasVojacek added the bug Confirmed reproducible bug label Oct 11, 2022
@kozlovic
Copy link
Member

The C client does the right thing there, by always using the default JS context or the option provided by individual calls. It looks like the Go client is using js.apiSubj() that only uses whatever is defined in the context, not in individual calls options.

@piotrpio
Copy link
Collaborator

It is actually a bit problematic right now, as you can pass any JSOpt to any of the methods of JetStreamManager, even if it does not make much sense (like e.g. configuring StreamPurgeRequest). I am working on a solution which would restrict using some options only to particular methods, but some of those options (like Domain() or APIPrefix()) seem to be good candidates to use in many methods, not just when creating JetStreamContext (like the C client does).

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

No branches or pull requests

5 participants