[release-11.4.4] InfluxDB: Fix nested variable interpolation (#104094)

InfluxDB: Fix nested variable interpolation (#104067)

Validate query type

(cherry picked from commit 519b75bd1e)
pull/104339/head
Andreas Christou 2 months ago committed by GitHub
parent 1285f8ca5a
commit 0c7510b5a9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 6
      public/app/plugins/datasource/influxdb/datasource.ts

@ -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;
}

Loading…
Cancel
Save