Changing dashboard variable does not change query

I have a Grafana instance with two Prometheus datasources (called “ds1” and “ds2”). To be able to select which datasource to use I’ve added a datasource variable (called “source”).

If I create a panel pinning the datasource to either “ds1” or “ds2” it works fine, I get the data from the right source.

But when using the datasource variable “${source}” as datasource I only get data from one of the sources, no matter what I select as satasource in the variable drop down. When inspecting the query, I notice that “request → data → queries[0] → datasource → uid” never changes, which explains why the data doesn’t change.

I’ve tested this locally in a Docker container using “grafana/grafana-oss:8.5.3” with default config with the same result.

What am I doing wrong/does not understand?

Turned out this was an regression in 8.5.x fixed in 8.5.4.