Incorrect variable interpolation for Performance queries when multiple variables have similar names
Description
When you have 2 variables defined in a Dashboard that have the same beginning of the name such as $node and $nodeId in a Performance query, the interpolation (replacing variables with actual values) may be incorrect.
If you use the one with the longer name, e.g. $nodeId, in a query, the interpolation may first match on the one with the shorter name ($node in this case). If the $nodeId value is 1, the interpolated value will end up being 1Id, i.e. $node being substituted with 1, then Id left as is.
The ends up causing the query to fail, e.g. looking for a resource with a node ID of 1Id instead of 1.
Solution is to add \b (word boundary) at the end of the regex, so that trying to match /\$node\b/ in "$nodeId" doesn’t match.
When you have 2 variables defined in a Dashboard that have the same beginning of the name such as
$node
and$nodeId
in a Performance query, the interpolation (replacing variables with actual values) may be incorrect.If you use the one with the longer name, e.g.
$nodeId
, in a query, the interpolation may first match on the one with the shorter name ($node
in this case). If the$nodeId
value is1
, the interpolated value will end up being1Id
, i.e.$node
being substituted with1
, thenId
left as is.The ends up causing the query to fail, e.g. looking for a resource with a node ID of
1Id
instead of1
.Solution is to add
\b
(word boundary) at the end of the regex, so that trying to match/\$node\b/
in"$nodeId"
doesn’t match.