[release-12.0.1] InfluxDB: Fix nested variable interpolation (#104176)

InfluxDB: Fix nested variable interpolation (#104067)

Validate query type

(cherry picked from commit 519b75bd1e)

Co-authored-by: Andreas Christou <andreas.christou@grafana.com>
This commit is contained in:
grafana-delivery-bot[bot]
2025-04-17 17:29:00 +01:00
committed by GitHub
co-authored by Andreas Christou
parent e94d5f0119
commit a6a5c77add
@@ -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;
}