Skip to content

Commit

Permalink
Add check for usage of new API in multiple filters
Browse files Browse the repository at this point in the history
Signed-off-by: Tomasz Pietrek <tomasz@nats.io>
  • Loading branch information
Jarema committed Jan 6, 2023
1 parent c8c4f8d commit 0090ee1
Show file tree
Hide file tree
Showing 4 changed files with 232 additions and 133 deletions.
10 changes: 10 additions & 0 deletions server/errors.json
Expand Up @@ -1328,5 +1328,15 @@
"help": "",
"url": "",
"deprecates": ""
},
{
"constant": "JsConsumerCantUseNewAPIWithMultipleSubjectFilters",
"code": 400,
"error_code": 10135,
"description": "Consumer with multiple subject filters cannot use subject based API",
"comment": "",
"help": "",
"url": "",
"deprecates": ""
}
]
7 changes: 7 additions & 0 deletions server/jetstream_api.go
Expand Up @@ -3813,6 +3813,13 @@ func (s *Server) jsConsumerCreateRequest(sub *subscription, c *client, a *Accoun
return
}

// in case of multiple filters provided, error if new API is used.
if filteredSubject != _EMPTY_ && len(req.Config.FilterSubjects) != 0 {
resp.Error = NewJsConsumerCantUseNewAPIWithMultipleSubjectFiltersError()
s.sendAPIErrResponse(ci, acc, subject, reply, string(msg), s.jsonResponse(&resp))
return
}

// Check for a filter subject.
if filteredSubject != _EMPTY_ && req.Config.FilterSubject != filteredSubject {
resp.Error = NewJSConsumerCreateFilterSubjectMismatchError()
Expand Down

0 comments on commit 0090ee1

Please sign in to comment.