Skip to content

Commit

Permalink
Return error when trying to update a stream with a source with a bad …
Browse files Browse the repository at this point in the history
…subject transform (#5574)

In some cases a bad subject transform could still pass the validation
test that is part of the config check when updating a stream config, and
no error would be returned. Now return an error when trying to update a
stream config with a source that has a bad subject transform that is not
caught by the subject transform destination check in the stream config
check.

Improves #5571

---------

Signed-off-by: Jean-Noël Moyne <jnmoyne@gmail.com>
  • Loading branch information
jnmoyne authored and neilalexander committed Jun 21, 2024
1 parent 08525ff commit bef3a5a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion server/jetstream_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22755,5 +22755,6 @@ func TestJetStreamBadSubjectMappingStream(t *testing.T) {
},
},
})
require_NoError(t, err)

require_Error(t, err, NewJSStreamUpdateError(errors.New("unable to get subject transform for source: invalid mapping destination: too many arguments passed to the function in {{wildcard(1)}}{{split(3,1)}}")))
}
3 changes: 2 additions & 1 deletion server/stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -1840,7 +1840,8 @@ func (mset *stream) updateWithAdvisory(config *StreamConfig, sendAdvisory bool)
var err error
si.trs[i], err = NewSubjectTransform(s.SubjectTransforms[i].Source, s.SubjectTransforms[i].Destination)
if err != nil {
mset.srv.Errorf("Unable to get subject transform for source: %v", err)
mset.mu.Unlock()
return fmt.Errorf("unable to get subject transform for source: %v", err)
}
}
}
Expand Down

0 comments on commit bef3a5a

Please sign in to comment.