From c13c6bc1f5af3eefa6ef1ad559fdd5fa747bd450 Mon Sep 17 00:00:00 2001 From: Carrie Edwards Date: Tue, 8 Jul 2025 14:13:37 -0700 Subject: [PATCH] Fix linting and failing tests Signed-off-by: Carrie Edwards --- promql/engine_test.go | 6 +++--- storage/type_unit_mismatch_storage.go | 18 +++++++----------- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/promql/engine_test.go b/promql/engine_test.go index 9bc1bd03bf..3866ad5ebf 100644 --- a/promql/engine_test.go +++ b/promql/engine_test.go @@ -3659,7 +3659,7 @@ func TestTypeUnitMismatchAnnotations(t *testing.T) { typeAndUnitLabelsEnabled: true, expectedWarningAnnotations: []string{}, expectedInfoAnnotations: []string{ - `PromQL info: mismatched type or unit metadata "series"`, + `PromQL info: mismatched type or unit metadata for metric "series"`, }, }, "info annotation when mismatched unit": { @@ -3671,7 +3671,7 @@ func TestTypeUnitMismatchAnnotations(t *testing.T) { typeAndUnitLabelsEnabled: true, expectedWarningAnnotations: []string{}, expectedInfoAnnotations: []string{ - `PromQL info: mismatched type or unit metadata "series"`, + `PromQL info: mismatched type or unit metadata for metric "series"`, }, }, "info annotation when mismatched type and unit": { @@ -3683,7 +3683,7 @@ func TestTypeUnitMismatchAnnotations(t *testing.T) { typeAndUnitLabelsEnabled: true, expectedWarningAnnotations: []string{}, expectedInfoAnnotations: []string{ - `PromQL info: mismatched type or unit metadata "series"`, + `PromQL info: mismatched type or unit metadata for metric "series"`, }, }, "no info annotation when type is unknown": { diff --git a/storage/type_unit_mismatch_storage.go b/storage/type_unit_mismatch_storage.go index 8c522b5904..44c0e34013 100644 --- a/storage/type_unit_mismatch_storage.go +++ b/storage/type_unit_mismatch_storage.go @@ -90,18 +90,14 @@ func (s *typeAndUnitMismatchSeriesSet) Next() bool { typ: mType, unit: mUnit, } - } else { - if s.prev.typ != mType || s.prev.unit != mUnit { - // Skip annotation if either type is "unknown" - this allows unknown to coexist with known types - if s.prev.typ == "unknown" || mType == "unknown" { - // Update to the known type if we have one - if s.prev.typ == "unknown" && mType != "unknown" { - s.prev.typ = mType - s.prev.unit = mUnit - } - } else { - s.annotations.Add(fmt.Errorf("%w for metric %q", annotations.MismatchedTypeOrUnitInfo, metric)) + } else if s.prev.typ != mType || s.prev.unit != mUnit { + if s.prev.typ == "unknown" || mType == "unknown" { + if s.prev.typ == "unknown" && mType != "unknown" { + s.prev.typ = mType + s.prev.unit = mUnit } + } else { + s.annotations.Add(fmt.Errorf("%w for metric %q", annotations.MismatchedTypeOrUnitInfo, metric)) } } return true