Conversation
Agent-Logs-Url: https://github.com/github/gh-aw/sessions/40bbec61-dc73-4fb0-aa5a-97a5823cd269 Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
- Add TemplateElseIfPattern to expression_patterns.go supporting all
syntax variants: {{#elseif}}, {{#else-if}}, {{#else_if}}, {{elseif}},
{{else-if}}, {{else_if}}
- Update wrapExpressionsInTemplateConditionals to wrap and normalise
elseif expressions to canonical {{#elseif}} form
- Update validateNoPreExpandedExperimentPlaceholders to check elseif
conditions for internal placeholder misuse
- Add selectBranch helper to interpolate_prompt.cjs and render_template.cjs
implementing multi-branch evaluation (if / elseif* / else?)
- Replace two-way else split with unified selectBranch in both JS engines
- Export selectBranch from both JS modules
- Add Go tests for elseif wrapping, normalisation, and validation
- Add JS tests for all elseif variants and branch selection logic
Agent-Logs-Url: https://github.com/github/gh-aw/sessions/40bbec61-dc73-4fb0-aa5a-97a5823cd269
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Address code review feedback: remove duplication by moving selectBranch from interpolate_prompt.cjs and render_template.cjs into a single shared template_branch.cjs module. Both consumers now require the shared module. Also clarify the wrapTagExpr closure comment in template.go. Agent-Logs-Url: https://github.com/github/gh-aw/sessions/40bbec61-dc73-4fb0-aa5a-97a5823cd269 Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
|
@copilot add tests, fuzz tests |
- Extend FuzzWrapExpressionsInTemplateConditionals seed corpus with all 6
elseif syntax variants and add invariant check that non-canonical elseif
forms are fully normalised to {{#elseif}} in the output
- Add fuzz_template_branch_harness.cjs JS harness for selectBranch and
renderMarkdownTemplate with elseif support
- Add fuzz_template_branch_harness.test.cjs with 18 seed-corpus test cases
covering all elseif syntax variants, multi-branch chains, equality
conditions, and crash-safety invariants
Agent-Logs-Url: https://github.com/github/gh-aw/sessions/fd7aa0eb-74aa-454e-bd7a-7d7eee453d71
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Added in commit Go fuzz test — extended JavaScript fuzz harness — new Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
Summary
Adds support for
{{#elseif expr}}(and multiple syntax variants) in template expression rendering, enabling multiple conditional branches in workflow prompts.Changes
Go compiler (
pkg/workflow/)expression_patterns.go: NewTemplateElseIfPatternregex matching all 6 elseif syntax variants:{{#elseif}},{{#else-if}},{{#else_if}},{{elseif}},{{else-if}},{{else_if}}template.go:wrapExpressionsInTemplateConditionalsnow wraps elseif expressions in${{ }}and normalises all variants to the canonical{{#elseif}}formtemplate_validation.go:validateNoPreExpandedExperimentPlaceholdersnow checks elseif conditions in addition to if conditions for internal__GH_AW_EXPERIMENTS_*__placeholder misuseJavaScript runtime (
actions/setup/js/)template_branch.cjs(new): SharedselectBranch(ifCondition, body)helper that evaluates the fullif / elseif* / else?branch chain usingString.splitwith capturing groups on the elseif patterninterpolate_prompt.cjsandrender_template.cjs: Both block and inline passes now delegate toselectBranchinstead of the previous two-way{{#else}}split, supporting arbitrarily many{{#elseif}}branchesTests
template_expression_wrapping_test.goTestValidateNoPreExpandedExperimentPlaceholders_ElseIfintemplate_include_validation_test.gointerpolate_prompt.test.cjsandrender_template.test.cjsFuzz tests
FuzzWrapExpressionsInTemplateConditionalsintemplate_fuzz_test.gowith seed corpus entries for all 6 elseif syntax variants and a property invariant asserting non-canonical elseif forms are fully normalised to{{#elseif}}in the outputfuzz_template_branch_harness.cjs— a JSON stdin/stdout fuzz harness forselectBranchandrenderMarkdownTemplate(matching the existing harness pattern)fuzz_template_branch_harness.test.cjswith 18 seed-corpus cases covering all syntax variants, multi-branch chains, equality conditions, and crash-safety invariantsSyntax variants supported
{{#if cond1}} Branch A {{#elseif cond2}} Branch B {{#else-if cond3}} Branch C {{#else_if cond4}} Branch D {{elseif cond5}} Branch E {{#else}} Fallback {{/if}}