Closed AetheWu closed 4 months ago
In addition, how to use nats.go to create stream partitions
I quickly created a test under server/jetstream_test.go
and added it and it does not fail, but does provide an error. I tested on main
, release/v2.10.17
and release/v2.10.16
branches.
// https://github.com/nats-io/nats-server/issues/5570
func TestJetStreamBadSubjectMappingStream(t *testing.T) {
s := RunBasicJetStreamServer(t)
defer s.Shutdown()
// Client for API requests.
nc, js := jsClientConnect(t, s)
defer nc.Close()
_, err := js.AddStream(&nats.StreamConfig{
Name: "test",
Sources: []*nats.StreamSource{
{
Name: "mapping",
SubjectTransforms: []nats.SubjectTransformConfig{
{
Source: "events.*",
Destination: "events.{{wildcard(1)}}{{split(3,1)}}",
},
},
},
},
})
require_NoError(t, err)
}
Although I do see a logic error @jnmoyne that you unlock the stream but do not return, so I can see where this would fail but the example above does not recreate it that error.
ok key is it has to be an update of an existing stream, not new one. I see it.
The mistake in your transform is that you need to put a '.' between the two transform functions (i.e. between {{wildcard(1)}} and {{split(3,1)}}).
And obviously it should handle that error better (thanks @derekcollison for taking care of that before I got to it!).
Observed behavior
We use nats-go sdk create a stream with below options:
The nats-server panic with below errors and is no longer running :
Expected behavior
do not panic
Server and client version
nats-server version: 2.10.16 nats-client: nats.go-1.36.0
Host environment
Deploy with official helm charts
Steps to reproduce
No response