fix nil pointer dereference (#51978)

This commit is contained in:
Artur Wierzbicki 2022-07-08 19:27:53 +04:00 committed by GitHub
parent 704a602d8c
commit c372b892ec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -35,7 +35,11 @@ func (d *datasourceVariableLookup) getDsRefsByTemplateVariableValue(value string
// get the actual default DS
candidateDs = d.dsLookup.ByRef(nil)
}
return []DataSourceRef{*candidateDs}
if candidateDs != nil {
return []DataSourceRef{*candidateDs}
}
return []DataSourceRef{}
case "$__all":
// TODO: filter datasources by template variable's regex
return d.dsLookup.ByType(datasourceType)