[release-11.5.4] InfluxDB: Fix nested variable interpolation (#104095)

InfluxDB: Fix nested variable interpolation (#104067)

Validate query type

(cherry picked from commit 519b75bd1e)
This commit is contained in:
Andreas Christou
2025-04-17 12:15:10 -04:00
committed by GitHub
parent 1db6d349a7
commit 754e62bae0
@@ -1,4 +1,4 @@
import { cloneDeep, extend, has, isString, map as _map, omit, pick, reduce } from 'lodash';
import { map as _map, cloneDeep, extend, has, isString, omit, pick, reduce } from 'lodash';
import { lastValueFrom, merge, Observable, of, throwError } from 'rxjs';
import { catchError, map } from 'rxjs/operators';
@@ -359,7 +359,9 @@ export default class InfluxDatasource extends DataSourceWithBackend<InfluxQuery,
// If matches are found this regex is evaluated to check if the variable is contained in the regex /^...$/ (^ and $ is optional)
// i.e. /^$myVar$/ or /$myVar/ or /^($myVar)$/
const regex = new RegExp(`\\/(?:\\^)?(.*)(\\$${variable.name})(.*)(?:\\$)?\\/`, 'gm');
if (!query) {
// We need to validate the type of the query as some legacy cases can pass a query value with a different type
if (!query || typeof query !== 'string') {
return value;
}