Skip to content

Commit fc7c018

Browse files
authored
fix: Fix nil pointer dereference in Volume method of the composite store (#18064)
If err is nil then calling the method Error() on it causes a nil pointer dereference. Signed-off-by: Christian Haudum <[email protected]>
1 parent 01ed3a0 commit fc7c018

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

pkg/storage/stores/composite_store_entry.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,10 +169,14 @@ func (c *storeEntry) Volume(ctx context.Context, userID string, from, through mo
169169
attribute.String("from", from.Time().String()),
170170
attribute.String("through", through.Time().String()),
171171
attribute.String("matchers", syntax.MatchersString(matchers)),
172-
attribute.String("err", err.Error()),
173172
attribute.Int("limit", int(limit)),
174173
attribute.String("aggregateBy", aggregateBy),
175174
)
175+
if err != nil {
176+
sp.SetAttributes(
177+
attribute.String("err", err.Error()),
178+
)
179+
}
176180

177181
return c.indexReader.Volume(ctx, userID, from, through, limit, targetLabels, aggregateBy, matchers...)
178182
}

0 commit comments

Comments
 (0)