Skip to content

[Bug?] Macro $__conditionalAll sets 1=1 in empty variable values #947

Closed
@sbengo

Description

@sbengo

What happened:
We have a Grafana selector that allows empty string values (''), which are valid in our context. However, when using the macro $__conditionAll, it is being replaced with 1=1, even though an empty string should be considered a valid selection.

For reference, the current documentation of the macro is as follows (README.md):

Macro Description Output example
$__conditionalAll(condition, $templateVar) Replaced by the first parameter when the template variable in the second parameter does not select every value. Replaced by the 1=1 when the template variable selects every value. condition or 1=1

What you expected to happen:
If the Grafana selector has an empty string value '', the macro $__conditionAll should not be replaced, as this value can be supported and is valid for applying the specific condition.

Code:

if (value === '' || value === '$__all') {

Questions:

  • Is there a specific reason why an empty string ('') is treated as all?

Environment:

  • Grafana version: 11.1.3
  • Plugin version: 4.0.8
  • OS Grafana is installed on: -
  • User OS & Browser: -
  • Others: -

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions