OPG-488: Fix issue with Performance query variable interpolation #1038
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
If you add 2 variables to a Dashboard and they both have the same beginning of the variable name, then if you use the one with the longer name in a Performance query, the variable interpolation will end up doing a partial match on the shorter variable name and doing the interpolation, adding the rest of the longer variable name onto the value.
Example: user adds
$node
and$nodeId
variables, both referencingnodeFilter()
, maybe$node
actually referencesnodeFilter(labelFormat=id:label,valueFormat=id)
.User uses
$nodeId
in a Performance Attribute query for the Node. They then try to set the Resource part of the query but it fails. Say$node
and$nodeId
were both set to a node Id of1
. Interpolation finds$node
, does a substitution on the string$nodeId
and results in1Id
. This is sent to the query to get resources and fails (node[1Id]
is not found).Solution is to add a word boundary to the regex before doing a replacement, e.g. do a regex match on
\$node\b
will fail on a string$nodeId
;\$nodeId\b
will correctly match.External References