From 40ce0a9d7eb95f90d081bb4d1f98699d74bfcf4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-No=C3=ABl=20Moyne?= Date: Tue, 19 Sep 2023 19:38:01 -0700 Subject: [PATCH] Use `filter_subject` when calling extended consumer create API MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The server consumer creation code is picky and does indeed not accept a request send to the ExT subject if that request specifies the subject filter in the array (even if there is only one entry in the array). Signed-off-by: Jean-Noël Moyne Signed-off-by: Neil Twigg Co-authored-by: Jean-Noël Moyne Co-authored-by: Neil Twigg --- server/stream.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/server/stream.go b/server/stream.go index e6f5f928..43f8f648 100644 --- a/server/stream.go +++ b/server/stream.go @@ -2895,7 +2895,11 @@ func (mset *stream) setSourceConsumer(iname string, seq uint64, startTime time.T subject = fmt.Sprintf(JSApiConsumerCreateExT, si.name, req.Config.Name, req.Config.FilterSubject) } else if len(req.Config.FilterSubjects) == 1 { req.Config.Name = fmt.Sprintf("src-%s", createConsumerName()) - subject = fmt.Sprintf(JSApiConsumerCreateExT, si.name, req.Config.Name, req.Config.FilterSubjects[0]) + // It is necessary to switch to using FilterSubject here as the extended consumer + // create API checks for it, so as to not accidentally allow multiple filtered subjects. + req.Config.FilterSubject = req.Config.FilterSubjects[0] + req.Config.FilterSubjects = nil + subject = fmt.Sprintf(JSApiConsumerCreateExT, si.name, req.Config.Name, req.Config.FilterSubject) } else { subject = fmt.Sprintf(JSApiConsumerCreateT, si.name) }