diff --git a/plugin/storage/badger/spanstore/read_write_test.go b/plugin/storage/badger/spanstore/read_write_test.go index 0c5f921dd76..91796387c0a 100644 --- a/plugin/storage/badger/spanstore/read_write_test.go +++ b/plugin/storage/badger/spanstore/read_write_test.go @@ -303,7 +303,7 @@ func TestFindNothing(t *testing.T) { trs, err := sr.FindTraces(context.Background(), params) assert.NoError(t, err) - assert.Equal(t, 0, len(trs)) + assert.Len(t, trs, 0) tr, err := sr.GetTrace(context.Background(), model.TraceID{High: 0, Low: 0}) assert.Equal(t, spanstore.ErrTraceNotFound, err) diff --git a/plugin/storage/badger/spanstore/reader.go b/plugin/storage/badger/spanstore/reader.go index c5d2ccf848f..b89020382b5 100644 --- a/plugin/storage/badger/spanstore/reader.go +++ b/plugin/storage/badger/spanstore/reader.go @@ -54,6 +54,9 @@ var ( // ErrNotSupported during development, don't support every option - yet ErrNotSupported = errors.New("this query parameter is not supported yet") + + // ErrInternalConsistencyError indicates internal data consistency issue + ErrInternalConsistencyError = errors.New("internal data consistency issue") ) const ( @@ -160,11 +163,14 @@ func (r *TraceReader) GetTrace(ctx context.Context, traceID model.TraceID) (*mod if err != nil { return nil, err } + if len(traces) == 0 { + return nil, spanstore.ErrTraceNotFound + } if len(traces) == 1 { return traces[0], nil } - return nil, spanstore.ErrTraceNotFound + return nil, ErrInternalConsistencyError } // scanTimeRange returns all the Traces found between startTs and endTs