Closed sloveridge closed 8 months ago
Hey!
Thanks for creating the issue.
Your suspicion is correct. Creating such a stream almost breaks the JetStream.
This is a know footgun that is hard to protect against it, as users might have a different set of tokens in JS
API prefix with imports and exports.
You can actually create such a stream with CLI too. Just delete all the streams you currently have.
The approach I am taking now to guard against this is to always add a fixed prefix to the subjects, either the stream name or an abbreviation of it.
e.g: "logs.*.*.*.*"
I assume this is sufficient to prevent this behaviour? Main downside here is wasted storage space and ensuring the prefix is added in the application code.
Definitely a footgun. The first error I had was KV creation not working. Took a while to trace it back to this.
There are only two ways you can get into trouble like this:
$JS.API
calls$JS.API
is imported from another accountSo yes, this should be sufficient to prevent such behavior.
Sorry that you hit that footgun. We're thinking how to improve that, but that is not obvious with given flexibility of setting up the JS prefixes.
I'm closing the issue. Feel free to reopen if you want to discuss it furhter. We are open to ideas how to improve that, however that is not Rust client specific thing.
Observed behavior
Creating a stream via the rust client with a subject of
"*.*.*.*"
or"*.*.*"
causes unexpected behaviour when listing streams via the cli. In addition, it will cause subsequent KV store creation to fail. Streams created with these subjects though the cli do not exhibit this behaviour.eg: after creating a stream "logs" with subject
"*.*.*.*"
via the rust client.nats stream ls
The stream itself has been created and shows correctly using info
nats stream info logs
It looks like the stream is listening to Internal JS messages
nats stream view logs
Attempting to create a KV afterwards via either the rust client or CLI will fail
nats kv add test
nats: error: nats: subjects overlap with an existing stream
Expected behavior
Rust client should act similar to the CLI when creating a stream with a subject of
"*.*.*.*"
Server and client version
nats-server: v2.10.11 async-nats: v0.3.3 nats-cli: v0.1.3
Host environment
Server started via
docker run -d --rm --name nats-test -p 4222:4222 nats:2.10.11 -js
Steps to reproduce
Stream created with the following will cause the issue:
Only using 2 * will not trigger the behaviour.