[v.10.2.x] Explore: lookup datasource by name when present in legacy URLs #87670
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Backport 867d36f from #85222
What is this feature?
This adds another check when loading legacy compact URLs so that their datasources are resolved correctly.
Why do we need this feature?
It appears that in older versions of Grafana, certain explore URLs in the "compact" format could have their datasource set on non-mixed queries using the name of the datasource. Prior to #66286 (up to v10.0.x), these were handled correctly because explore would take no action on modifying the queries unless their datasource fields were not all the same. Even if they were not, it would choose the datasource as set on the first query but retain the others to be treated as imported queries.
In Grafana 10.1.X this behavior changed to remove all queries whose
datasource
field was set and not equal to that of the root value. In particular, the code assumes that if the field is set to a string then it is the datasource UID. Since it is instead the name in these URLs, the queries are removed by the filter.By modifying the filter to allow the name these URLs work again correctly in the latest version of Grafana. Since the decision was made to continue supporting legacy URLs, it seems appropriate to fix this.
Who is this feature for?
This is likely most useful for long term users of Grafana who may have older explore URLs sprinkled in docs, code comments, or other tooling.
Special notes for your reviewer:
Please check that: