From ae7a254aa3a22846683b59dba80af488ae1d36fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gy=C3=B6rgy=20Krajcsovits?= Date: Fri, 19 Sep 2025 09:43:55 +0200 Subject: [PATCH] better errors naming and formatting, typo fixes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: György Krajcsovits --- storage/remote/codec.go | 4 ++-- storage/remote/codec_test.go | 9 +++++---- tsdb/chunkenc/float_histogram_test.go | 4 ++-- tsdb/chunkenc/histogram_test.go | 4 ++-- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/storage/remote/codec.go b/storage/remote/codec.go index 5590ac4a50..7e21909354 100644 --- a/storage/remote/codec.go +++ b/storage/remote/codec.go @@ -472,10 +472,10 @@ func (c *concreteSeriesIterator) Seek(t int64) chunkenc.ValueType { } func validateHistogramSchema(h *prompb.Histogram) error { - if histogram.IsAcceptibleSchema(h.Schema) { + if histogram.IsKnownSchema(h.Schema) { return nil } - return histogram.InvalidSchemaError(h.Schema) + return histogram.UnknownSchemaError(h.Schema) } func getHistogramValType(h *prompb.Histogram) chunkenc.ValueType { diff --git a/storage/remote/codec_test.go b/storage/remote/codec_test.go index da96519b70..ddf8f76cf6 100644 --- a/storage/remote/codec_test.go +++ b/storage/remote/codec_test.go @@ -570,24 +570,25 @@ func TestConcreteSeriesIterator_InvalidHistogramSamples(t *testing.T) { require.Equal(t, chunkenc.ValFloat, it.Next()) require.Equal(t, chunkenc.ValNone, it.Next()) require.Error(t, it.Err()) + require.ErrorIs(t, it.Err(), histogram.ErrHistogramsUnknownSchema) it = series.Iterator(it) require.Equal(t, chunkenc.ValFloat, it.Next()) require.Equal(t, chunkenc.ValNone, it.Next()) - require.Error(t, it.Err()) + require.ErrorIs(t, it.Err(), histogram.ErrHistogramsUnknownSchema) it = series.Iterator(it) require.Equal(t, chunkenc.ValNone, it.Seek(1)) - require.Error(t, it.Err()) + require.ErrorIs(t, it.Err(), histogram.ErrHistogramsUnknownSchema) it = series.Iterator(it) require.Equal(t, chunkenc.ValFloat, it.Seek(3)) require.Equal(t, chunkenc.ValNone, it.Next()) - require.Error(t, it.Err()) + require.ErrorIs(t, it.Err(), histogram.ErrHistogramsUnknownSchema) it = series.Iterator(it) require.Equal(t, chunkenc.ValNone, it.Seek(4)) - require.Error(t, it.Err()) + require.ErrorIs(t, it.Err(), histogram.ErrHistogramsUnknownSchema) }) } } diff --git a/tsdb/chunkenc/float_histogram_test.go b/tsdb/chunkenc/float_histogram_test.go index 7f7e2fdbf0..d112c81f1c 100644 --- a/tsdb/chunkenc/float_histogram_test.go +++ b/tsdb/chunkenc/float_histogram_test.go @@ -1488,12 +1488,12 @@ func TestFloatHistogramIteratorFailIfSchemaInValid(t *testing.T) { it := c.Iterator(nil) require.Equal(t, ValNone, it.Next()) - require.ErrorIs(t, it.Err(), histogram.ErrHistogramsInvalidSchema) + require.ErrorIs(t, it.Err(), histogram.ErrHistogramsUnknownSchema) }) } } -func TestFloatHistogramIteratorReduceShema(t *testing.T) { +func TestFloatHistogramIteratorReduceSchema(t *testing.T) { for _, schema := range []int32{9, 52} { t.Run(fmt.Sprintf("schema %d", schema), func(t *testing.T) { h := &histogram.FloatHistogram{ diff --git a/tsdb/chunkenc/histogram_test.go b/tsdb/chunkenc/histogram_test.go index 11606024d4..4213313acc 100644 --- a/tsdb/chunkenc/histogram_test.go +++ b/tsdb/chunkenc/histogram_test.go @@ -1844,12 +1844,12 @@ func TestHistogramIteratorFailIfSchemaInValid(t *testing.T) { it := c.Iterator(nil) require.Equal(t, ValNone, it.Next()) - require.ErrorIs(t, it.Err(), histogram.ErrHistogramsInvalidSchema) + require.ErrorIs(t, it.Err(), histogram.ErrHistogramsUnknownSchema) }) } } -func TestHistogramIteratorReduceShema(t *testing.T) { +func TestHistogramIteratorReduceSchema(t *testing.T) { for _, schema := range []int32{9, 52} { t.Run(fmt.Sprintf("schema %d", schema), func(t *testing.T) { h := &histogram.Histogram{