diff --git a/jetstream/kv.go b/jetstream/kv.go index c16c57146..3f5f24aff 100644 --- a/jetstream/kv.go +++ b/jetstream/kv.go @@ -411,7 +411,7 @@ func (js *jetStream) KeyValueStoreNames(ctx context.Context) KeyValueNamesLister if !strings.HasPrefix(name, kvBucketNamePre) { continue } - res.kvNames <- name + res.kvNames <- strings.TrimPrefix(name, kvBucketNamePre) } if errors.Is(err, ErrEndOfData) { return diff --git a/jetstream/test/kv_test.go b/jetstream/test/kv_test.go index 788a31896..cc0b556cb 100644 --- a/jetstream/test/kv_test.go +++ b/jetstream/test/kv_test.go @@ -995,6 +995,9 @@ func TestListKeyValueStores(t *testing.T) { names := make([]string, 0) kvNames := js.KeyValueStoreNames(ctx) for name := range kvNames.Name() { + if strings.HasPrefix(name, "KV_") { + t.Fatalf("Expected name without KV_ prefix, got %q", name) + } names = append(names, name) } if kvNames.Error() != nil { diff --git a/kv.go b/kv.go index ed4edc391..2e7ce6e55 100644 --- a/kv.go +++ b/kv.go @@ -1062,7 +1062,7 @@ func (js *js) KeyValueStoreNames() <-chan string { if !strings.HasPrefix(name, kvBucketNamePre) { continue } - ch <- name + ch <- strings.TrimPrefix(name, kvBucketNamePre) } } }() diff --git a/test/kv_test.go b/test/kv_test.go index afa937de5..92de2c982 100644 --- a/test/kv_test.go +++ b/test/kv_test.go @@ -979,6 +979,9 @@ func TestListKeyValueStores(t *testing.T) { } names := make([]string, 0) for name := range js.KeyValueStoreNames() { + if strings.HasPrefix(name, "KV_") { + t.Fatalf("Expected name without KV_ prefix, got %q", name) + } names = append(names, name) } if len(names) != test.bucketsNum {