Skip to content

fix: convert double quotes to single quotes in experiment comparison expressions#31770

Merged
pelikhan merged 3 commits into
mainfrom
copilot/fix-syntax-issue-multi-candidate
May 12, 2026
Merged

fix: convert double quotes to single quotes in experiment comparison expressions#31770
pelikhan merged 3 commits into
mainfrom
copilot/fix-syntax-issue-multi-candidate

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 12, 2026

Bug Fix

What was the bug?

GitHub Actions ${{ }} expressions only support single-quoted string literals. The compiler's transformExperimentsExpression was passing double quotes through verbatim when rewriting experiments.<name> == "value" to steps.pick-experiment.outputs.<name> == "value", producing expressions rejected at workflow parse time.

How did you fix it?

  • pkg/workflow/expression_extraction.go: transformExperimentsExpression now replaces "' in the comparison remainder. Updated experimentComparisonRegex to also accept single-quoted input (making re-compilation idempotent).
// Before
return "steps.pick-experiment.outputs." + m[1] + m[2]
// ${{ steps.pick-experiment.outputs.reasoning_depth == "multi_candidate" }}  ❌

// After
remainder := strings.ReplaceAll(m[2], `"`, `'`)
return "steps.pick-experiment.outputs." + m[1] + remainder
// ${{ steps.pick-experiment.outputs.reasoning_depth == 'multi_candidate' }}  ✅
  • 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 changed GH_AW_EXPR_DD64DF46GH_AW_EXPR_CBA23170).

Copilot AI and others added 2 commits May 12, 2026 18:55
… 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 AI changed the title Fix GitHub Actions expression syntax: convert double quotes to single quotes in experiment comparisons fix: convert double quotes to single quotes in experiment comparison expressions May 12, 2026
Copilot AI requested a review from pelikhan May 12, 2026 19:00
@pelikhan pelikhan marked this pull request as ready for review May 12, 2026 19:11
Copilot AI review requested due to automatic review settings May 12, 2026 19:11
@pelikhan
Copy link
Copy Markdown
Collaborator

@copilot the compiler should also complain about using single quotes in expressions so that the agent fixes it

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 experimentComparisonRegex and transformExperimentsExpression to 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.yml to 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], `"`, `'`)
Comment on lines +242 to +247
// 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], `"`, `'`)
@pelikhan
Copy link
Copy Markdown
Collaborator

@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>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented May 12, 2026

@copilot the compiler should also complain about using single quotes in expressions so that the agent fixes it

Done. The compiler now emits a warning when experiment comparison expressions in the source markdown use double-quoted string literals (e.g. {{#if experiments.mode == "detail"}}), pointing authors to use single quotes instead. The warning is surfaced via detectDoubleQuotedExperimentComparisons in template_validation.go and wired into compiler_orchestrator_frontmatter.go.

I also fixed daily-fact.md to use single quotes at the source so the warning no longer fires on that file.

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.

3 participants