Skip to content

promql: fix panic with @ modifier on empty ranges#18020

Merged
bwplotka merged 1 commit intoprometheus:mainfrom
roidelapluie:roidelapluie/fixPromQLPanic
Feb 6, 2026
Merged

promql: fix panic with @ modifier on empty ranges#18020
bwplotka merged 1 commit intoprometheus:mainfrom
roidelapluie:roidelapluie/fixPromQLPanic

Conversation

@roidelapluie
Copy link
Member

@roidelapluie roidelapluie commented Feb 5, 2026

When using the @ modifier with a timestamp that has no data, several PromQL range functions were panicking with "index out of range [0] with length 0". This was introduced by #16797 which changed function signatures to use concrete types instead of interfaces.

The panic occurred because functions were accessing array elements (matrixVal[0], vectorVals[0][0]) without checking if the arrays were empty first.

Fixes #18018

Which issue(s) does the PR fix:

Does this PR introduce a user-facing change?

[BUGFIX] PromQL: Fix panic with @ modifier on empty ranges

When using the @ modifier with a timestamp that has no data, several
PromQL range functions were panicking with "index out of range [0]
with length 0". This was introduced by prometheus#16797 which changed function
signatures to use concrete types instead of interfaces.

The panic occurred because functions were accessing array elements
(matrixVal[0], vectorVals[0][0]) without checking if the arrays were
empty first.

Fixes prometheus#18018

Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com>
Copy link
Contributor

@yeya24 yeya24 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the prompt fix!

Copy link
Member

@bwplotka bwplotka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@bwplotka bwplotka merged commit eaf4779 into prometheus:main Feb 6, 2026
32 of 33 checks passed
wbollock pushed a commit to wbollock/prometheus that referenced this pull request Feb 6, 2026
When using the @ modifier with a timestamp that has no data, several
PromQL range functions were panicking with "index out of range [0]
with length 0". This was introduced by prometheus#16797 which changed function
signatures to use concrete types instead of interfaces.

The panic occurred because functions were accessing array elements
(matrixVal[0], vectorVals[0][0]) without checking if the arrays were
empty first.

Fixes prometheus#18018

Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com>
Signed-off-by: Will Bollock <wbollock@linode.com>
wbollock pushed a commit to wbollock/prometheus that referenced this pull request Feb 6, 2026
When using the @ modifier with a timestamp that has no data, several
PromQL range functions were panicking with "index out of range [0]
with length 0". This was introduced by prometheus#16797 which changed function
signatures to use concrete types instead of interfaces.

The panic occurred because functions were accessing array elements
(matrixVal[0], vectorVals[0][0]) without checking if the arrays were
empty first.

Fixes prometheus#18018

Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com>
wbollock pushed a commit to wbollock/prometheus that referenced this pull request Feb 6, 2026
When using the @ modifier with a timestamp that has no data, several
PromQL range functions were panicking with "index out of range [0]
with length 0". This was introduced by prometheus#16797 which changed function
signatures to use concrete types instead of interfaces.

The panic occurred because functions were accessing array elements
(matrixVal[0], vectorVals[0][0]) without checking if the arrays were
empty first.

Fixes prometheus#18018

Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com>
wbollock pushed a commit to wbollock/prometheus that referenced this pull request Feb 6, 2026
When using the @ modifier with a timestamp that has no data, several
PromQL range functions were panicking with "index out of range [0]
with length 0". This was introduced by prometheus#16797 which changed function
signatures to use concrete types instead of interfaces.

The panic occurred because functions were accessing array elements
(matrixVal[0], vectorVals[0][0]) without checking if the arrays were
empty first.

Fixes prometheus#18018

Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com>
wbollock pushed a commit to wbollock/prometheus that referenced this pull request Feb 6, 2026
When using the @ modifier with a timestamp that has no data, several
PromQL range functions were panicking with "index out of range [0]
with length 0". This was introduced by prometheus#16797 which changed function
signatures to use concrete types instead of interfaces.

The panic occurred because functions were accessing array elements
(matrixVal[0], vectorVals[0][0]) without checking if the arrays were
empty first.

Fixes prometheus#18018

Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com>
wbollock pushed a commit to wbollock/prometheus that referenced this pull request Feb 6, 2026
When using the @ modifier with a timestamp that has no data, several
PromQL range functions were panicking with "index out of range [0]
with length 0". This was introduced by prometheus#16797 which changed function
signatures to use concrete types instead of interfaces.

The panic occurred because functions were accessing array elements
(matrixVal[0], vectorVals[0][0]) without checking if the arrays were
empty first.

Fixes prometheus#18018

Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PromQL: engine panics with @ modifier on empty ranges for several range functions

3 participants