fix: convert double quotes to single quotes in experiment comparison expressions#31770
Conversation
… quotes in experiment comparison expressions
In GitHub Actions, string literals inside ${{ }} expressions must use single
quotes. The compiler was preserving double quotes from template conditionals like
{{#if experiments.reasoning_depth == "multi_candidate"}}, producing invalid
expressions such as ${{ steps.pick-experiment.outputs.reasoning_depth == "multi_candidate" }}.
Fix transformExperimentsExpression to replace double quotes with single quotes in
the comparison remainder, and update experimentComparisonRegex to also accept
single-quoted values as input. Recompile daily-fact.lock.yml to apply the fix.
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
|
@copilot the compiler should also complain about using single quotes in expressions so that the agent fixes it |
There was a problem hiding this comment.
Pull request overview
Fixes GitHub Actions expression compilation for experiments.<name> == <string> by ensuring generated ${{ }} expressions use single-quoted string literals (and accepting single-quoted input to keep recompilation idempotent).
Changes:
- Updated
experimentComparisonRegexandtransformExperimentsExpressionto normalize comparison string literals to single quotes. - Adjusted unit tests to expect single-quoted output and added coverage for single-quoted input.
- Recompiled
daily-fact.lock.ymlto reflect updated expression hashing/output (including updated placeholder/env-var names).
Show a summary per file
| File | Description |
|---|---|
| pkg/workflow/expression_extraction.go | Updates experiment-comparison detection/rewriting and normalizes quotes for Actions expression compatibility. |
| pkg/workflow/expression_extraction_test.go | Updates expectations for rewritten expressions and adds a single-quoted input test case. |
| .github/workflows/daily-fact.lock.yml | Recompiled workflow lock output reflecting the quote normalization and resulting hash-based env var rename. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 3/3 changed files
- Comments generated: 2
| // This replacement is safe because experimentComparisonRegex guarantees | ||
| // that quotes only appear as delimiters around the string literal value; | ||
| // no embedded quotes of the same kind are allowed by the pattern. | ||
| remainder := strings.ReplaceAll(m[2], `"`, `'`) |
| // Convert double quotes to single quotes: GitHub Actions expressions only | ||
| // support single-quoted string literals, not double-quoted ones. | ||
| // This replacement is safe because experimentComparisonRegex guarantees | ||
| // that quotes only appear as delimiters around the string literal value; | ||
| // no embedded quotes of the same kind are allowed by the pattern. | ||
| remainder := strings.ReplaceAll(m[2], `"`, `'`) |
|
@copilot review all comments |
…ons; fix daily-fact.md source to use single quotes
When an experiment comparison expression uses double-quoted string literals
(e.g. {{#if experiments.mode == "value"}}), the compiler now emits a warning
prompting authors to use single quotes instead, consistent with GitHub Actions
expression syntax requirements.
Changes:
- pkg/workflow/template_validation.go: add experimentDoubleQuotePattern regex and
detectDoubleQuotedExperimentComparisons() function
- pkg/workflow/compiler_orchestrator_frontmatter.go: import console package and
emit a warning + increment warning count for each double-quoted comparison found
- pkg/workflow/template_include_validation_test.go: add TestDetectDoubleQuotedExperimentComparisons
- pkg/workflow/compiler_template_validation_test.go: update test fixture to use single quotes
(avoids spurious warning emission during testing)
- .github/workflows/daily-fact.md: fix source to use single quotes
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Done. The compiler now emits a warning when experiment comparison expressions in the source markdown use double-quoted string literals (e.g. I also fixed |
Bug Fix
What was the bug?
GitHub Actions
${{ }}expressions only support single-quoted string literals. The compiler'stransformExperimentsExpressionwas passing double quotes through verbatim when rewritingexperiments.<name> == "value"tosteps.pick-experiment.outputs.<name> == "value", producing expressions rejected at workflow parse time.How did you fix it?
pkg/workflow/expression_extraction.go:transformExperimentsExpressionnow replaces"→'in the comparison remainder. UpdatedexperimentComparisonRegexto also accept single-quoted input (making re-compilation idempotent).pkg/workflow/expression_extraction_test.go: Updated four existing assertions to expect single-quoted output; added a test case for single-quoted input..github/workflows/daily-fact.lock.yml: Recompiled — three"multi_candidate"occurrences are now'multi_candidate'(env var key changedGH_AW_EXPR_DD64DF46→GH_AW_EXPR_CBA23170).