From dfa3f630314f8328ee158b25e6c1968397cdd80d Mon Sep 17 00:00:00 2001 From: Congqi Xia Date: Thu, 7 Nov 2024 16:12:11 +0800 Subject: [PATCH] fix: Escape brace for dumped JSON for index err message Related to #37503 Signed-off-by: Congqi Xia --- internal/core/src/index/VectorMemIndex.cpp | 12 +++--- internal/datacoord/mock_channel_store.go | 46 ++++++++++++++++++++++ 2 files changed, 53 insertions(+), 5 deletions(-) diff --git a/internal/core/src/index/VectorMemIndex.cpp b/internal/core/src/index/VectorMemIndex.cpp index 2f77e8ffbb6af..c471fb02a1325 100644 --- a/internal/core/src/index/VectorMemIndex.cpp +++ b/internal/core/src/index/VectorMemIndex.cpp @@ -408,11 +408,13 @@ VectorMemIndex::Query(const DatasetPtr dataset, auto res = index_.Search(dataset, search_conf, bitset); milvus::tracer::AddEvent("finish_knowhere_index_search"); if (!res.has_value()) { - PanicInfo(ErrorCode::UnexpectedError, - "failed to search: config={} {}: {}", - search_conf.dump(), - KnowhereStatusString(res.error()), - res.what()); + PanicInfo( + ErrorCode::UnexpectedError, + // escape json brace in case of using message as format + "failed to search: config={{{}}} {}: {}", + search_conf.dump(), + KnowhereStatusString(res.error()), + res.what()); } return res.value(); } diff --git a/internal/datacoord/mock_channel_store.go b/internal/datacoord/mock_channel_store.go index f14691c8abbc9..a416692c7db09 100644 --- a/internal/datacoord/mock_channel_store.go +++ b/internal/datacoord/mock_channel_store.go @@ -350,6 +350,52 @@ func (_c *MockRWChannelStore_GetNodesChannels_Call) RunAndReturn(run func() []*N return _c } +// HasChannel provides a mock function with given fields: channel +func (_m *MockRWChannelStore) HasChannel(channel string) bool { + ret := _m.Called(channel) + + if len(ret) == 0 { + panic("no return value specified for HasChannel") + } + + var r0 bool + if rf, ok := ret.Get(0).(func(string) bool); ok { + r0 = rf(channel) + } else { + r0 = ret.Get(0).(bool) + } + + return r0 +} + +// MockRWChannelStore_HasChannel_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'HasChannel' +type MockRWChannelStore_HasChannel_Call struct { + *mock.Call +} + +// HasChannel is a helper method to define mock.On call +// - channel string +func (_e *MockRWChannelStore_Expecter) HasChannel(channel interface{}) *MockRWChannelStore_HasChannel_Call { + return &MockRWChannelStore_HasChannel_Call{Call: _e.mock.On("HasChannel", channel)} +} + +func (_c *MockRWChannelStore_HasChannel_Call) Run(run func(channel string)) *MockRWChannelStore_HasChannel_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(string)) + }) + return _c +} + +func (_c *MockRWChannelStore_HasChannel_Call) Return(_a0 bool) *MockRWChannelStore_HasChannel_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockRWChannelStore_HasChannel_Call) RunAndReturn(run func(string) bool) *MockRWChannelStore_HasChannel_Call { + _c.Call.Return(run) + return _c +} + // Reload provides a mock function with given fields: func (_m *MockRWChannelStore) Reload() error { ret := _m.Called()