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

Add error and its check for collision with JS API #3532

Closed
wants to merge 5 commits into from

Conversation

AlbericC
Copy link

@AlbericC AlbericC commented Oct 8, 2022

  • Link to issue, e.g. Resolves #NNN
  • Documentation added (if applicable)
  • Tests added
  • Branch rebased on top of current main (git pull --rebase origin main)
  • Changes squashed to a single commit (described here)
  • Build is green in Travis CI
  • You have certified that the contribution is your original work and that you license the work to the project under the Apache 2 license

Resolves #3531

Changes proposed in this pull request:

  • check for collision with JS API when account creates a stream
  • New error for this case

/cc @nats-io/core

@AlbericC AlbericC marked this pull request as draft October 8, 2022 15:26
server/stream.go Outdated
@@ -1147,6 +1147,12 @@ func (s *Server) checkStreamCfg(config *StreamConfig, acc *Account) (StreamConfi
}
}

for _, subj := range cfg.Subjects {
if SubjectsCollide(subj, JSApiPrefix) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will help of course - we planned to add this before but with cross accounts, domains etc it’s a mine field. And of course many other subjects are problematic also.

We should for sure also stop just “>” for example also

Copy link
Contributor

@ripienaar ripienaar Oct 8, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this should stop > also though as it would over lap

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that was my first thought also, but with (possibly) exported JetStream services, I wanted to target the JS API more specifically.

Although '>' sure poses a problem every time, I can imagine a (twisted) use-case where one would want to use a stream to keep an history of $JS.EVENT.ADVISORY.> for instance.

Copy link
Contributor

@ripienaar ripienaar Oct 8, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah so we definitely shouldn’t stop advisories from being ingested that’s a good point.

And to be pedantic you CAN ingest > you just need to turn off ack on the stream.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do seem to recall some users having a stream on the API subject without acks for audit purposes.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pretty good point I'll take that into account and correct my code accordingly

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for the record a test exists to ensure events, etc are OK

// Events and Advisories etc should be ok.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this should stop > also though as it would over lap

yes, it does. Included a test case for it to make that explicit

@AlbericC
Copy link
Author

AlbericC commented Oct 8, 2022

I made this pull request kind of quick, do not hesitate to reject it if you want me to do it again in a cleaner way (branched, rebased, squashed).

@AlbericC AlbericC marked this pull request as ready for review October 8, 2022 17:47
Copy link
Member

@kozlovic kozlovic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since I would consider this a breaking change (since possibly existing streams would fail to be recovered, etc..) should this go only on the next 2.10.0 release? I have created the dev branch today that will hold the changes in main (the patches) and all PRs that are targeted for the next release. If we all agree that this is possibly breaking and should go in 2.10.0, could you alter your PR to be against the dev branch instead of main?

@bruth
Copy link
Member

bruth commented Apr 23, 2023

An undertone of this PR is the need to extend the authorization model transparently for JetStream primitives. That said, there may be an incremental improvement here as an opt-in (non-breaking) account limit that could guard against creating streams that bind to the JS API.

@wallyqs
Copy link
Member

wallyqs commented Aug 28, 2024

Addressed via #5548

@wallyqs wallyqs closed this Aug 28, 2024
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

Successfully merging this pull request may close these issues.

Setting up a stream over JS API subject breaks the API
6 participants