Variable Dropdown Retains Previous Options When Query Returns No Results (PostgreSQL)
What Grafana version and what operating system are you using?
-
Grafana: 13.x
-
Data Source: PostgreSQL
-
Operating System: Linux (Docker)
What are you trying to achieve?
I am using dependent dashboard variables where the available options in a child variable depend on the selection of a parent variable.
I expect the dropdown options to always reflect the current query result.
How are you trying to achieve it?
I have query-based PostgreSQL variables.
For example:
-
Variable A (parent)
-
Variable B (child, depends on Variable A)
When Variable A changes, Variable B is refreshed using a PostgreSQL query.
What happened?
When the child variable query returns data, the dropdown options are updated correctly.
However, if the parent variable changes and the child variable query subsequently returns no rows, the dropdown still displays the options that were returned by the previous query execution.
When I inspect the variable query in Grafana, the query result is empty and no rows are returned.
Despite this, the old options remain visible in the variable dropdown and a warning icon appears next to the variable.
It appears that the previous variable options are being preserved even though they are no longer returned by the query.
What did you expect to happen?
If the variable query returns no rows, I would expect the variable dropdown to become empty and display no available options.
I would not expect options from a previous query execution to remain visible in the dropdown.
Can you copy/paste the configuration(s) that you are having problems with?
Example query:
SELECT sensor_id
FROM sensors
WHERE node_id IN (${nodeid})
ORDER BY sensor_id
The issue occurs whenever the refreshed query returns no rows.
Did you receive any errors in the Grafana UI or in related logs? If so, please tell us exactly what they were.
No server-side errors appear in Grafana logs.
The variable displays a warning icon in the dashboard UI indicating that the variable state is invalid or outdated.
Did you follow any online instructions? If so, what is the URL?
No.
Additional Information
To clarify, the issue is not that the previous value remains selected.
The issue is that the previous variable options remain visible in the dropdown even though the current query result is empty.
Is this expected behavior, a caching issue, or a bug in Grafana 13.x variable handling?


