diff --git a/promql/parser/printer.go b/promql/parser/printer.go index e81e4ca7b2..703dd095d4 100644 --- a/promql/parser/printer.go +++ b/promql/parser/printer.go @@ -174,7 +174,7 @@ func (node *BinaryExpr) getMatchingStr() string { } if vm.FillValues.LHS != nil || vm.FillValues.RHS != nil { - if vm.FillValues.LHS == vm.FillValues.RHS { + if vm.FillValues.LHS != nil && vm.FillValues.RHS != nil && *vm.FillValues.LHS == *vm.FillValues.RHS { matching += fmt.Sprintf(" fill (%v)", *vm.FillValues.LHS) } else { if vm.FillValues.LHS != nil { diff --git a/promql/parser/printer_test.go b/promql/parser/printer_test.go index 786109ab9d..8be35d9a48 100644 --- a/promql/parser/printer_test.go +++ b/promql/parser/printer_test.go @@ -130,6 +130,10 @@ func TestExprString(t *testing.T) { in: `a + fill_left(-23) fill_right(42) b`, out: `a + fill_left (-23) fill_right (42) b`, }, + { + in: `a + fill_left(5) fill_right(5) b`, + out: `a + fill (5) b`, + }, { in: `a + on(b) group_left fill(-23) c`, out: `a + on (b) group_left () fill (-23) c`,