Repository navigation
Fix $__multiVar for values that contain spaces - #814
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Escape embedded quotes and backslashes and add a regression test.
1 open issue
What changed in this PR
Fixes $__multiVar so multi-word values are quoted for GitHub search.
Changes:
- Added quoting for whitespace-containing values.
- Added interpolation tests.
- Updated template-variable documentation.
A remaining moderate issue is that embedded quotes and backslashes are not escaped before wrapping values.
| File | Summary |
|---|---|
pkg/github/macros.go |
Quotes whitespace-containing qualifier values. |
pkg/github/macros_test.go |
Tests new quoting behavior. |
docs/sources/template-variables.md |
Documents quoted values. |
Review effort: Lite
adamyeats
approved these changes
Nov 13, 2026
adamyeats
left a comment
Contributor
There was a problem hiding this comment.
@RaphaelFakhri LGTM, thanks! Keeping already-quoted values as they are is a nice touch, since it doesn't break anyone who quoted them by hand.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.

Type of Change
Bug Fix
What is the bug?
$__multiVar(qualifier,$var)writes each selected value asqualifier:valuewithout quotes. When a value contains a space, GitHub search reads only the first word as the qualifier value and treats the rest as free text. For example, selecting the labelsgood first issueandbugexpands tolabel:good first issue label:bug, which searches for the labelgoodplus the textfirst issue, so the query misses the issues labeledgood first issue.This change wraps values that contain whitespace in double quotes, so the same selection expands to
label:"good first issue" label:bug. Values that are already quoted and values without spaces are unchanged.How to reproduce
is:open $__multiVar(label,$labels)withlabelsset togood first issueandbugproducesis:open label:good first issue label:bug.grafana/grafana:is:open label:good first issuereturns 0 issues, andis:open label:"good first issue"returns 18.Related Issues
Closes #813
Environment (if no related issue)
main)Please check that:
Special notes for your reviewer
The quoting happens in the backend macro, so it applies to every query type that interpolates macros. The new cases in
TestInterPolateMacroscover a value with spaces and a value that is already quoted.