Skip to content

support object-form template variable queries - #128

Merged
JackieTien97 merged 1 commit into
apache:masterfrom
CoollZzz:feat/fix-grafana-variable-query-object
Aug 25, 2026
Merged

support object-form template variable queries#128
JackieTien97 merged 1 commit into
apache:masterfrom
CoollZzz:feat/fix-grafana-variable-query-object

Conversation

@CoollZzz

@CoollZzz CoollZzz commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

This pull request improves the robustness and compatibility of the metricFindQuery method in the DataSource class, ensuring it can handle both modern and legacy variable query formats, and adds comprehensive test coverage for these cases.

Enhancements to variable query handling:

  • Added a new helper function variableQueryText to safely extract the query string from either a string or an object with a query field, ensuring type safety and flexibility.
  • Updated the metricFindQuery method to use variableQueryText, rejecting any variable query that is neither a string nor an object with a string query field, and providing a clear error message in such cases.

Testing improvements:

  • Added a new test suite for metricFindQuery covering:
    • Standard variable query objects with template expansion.
    • Legacy string-based variable queries for backward compatibility.
    • Error handling for invalid query object formats.

@JackieTien97
JackieTien97 merged commit ca2d615 into apache:master Aug 25, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants