-
Notifications
You must be signed in to change notification settings - Fork 351
fix: skip boolean/null literal wrapping in runtime imports #25831
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -1498,14 +1498,17 @@ describe("runtime_import", () => { | |||||||||||||||||||||||||||||||||||||||||||||||||||
| it("should wrap {{#if steps.foo.outputs.bar}}", () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| expect(wrapExpressionsInTemplateConditionals("{{#if steps.foo.outputs.bar}}body{{/if}}")).toBe("{{#if ${{ steps.foo.outputs.bar }} }}body{{/if}}"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| it("should wrap {{#if true}}", () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| expect(wrapExpressionsInTemplateConditionals("{{#if true}}body{{/if}}")).toBe("{{#if ${{ true }} }}body{{/if}}"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| describe("boolean/null literals — must be left unchanged for direct isTruthy() evaluation", () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| it("should leave {{#if true}} unchanged", () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| expect(wrapExpressionsInTemplateConditionals("{{#if true}}body{{/if}}")).toBe("{{#if true}}body{{/if}}"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| it("should wrap {{#if false}}", () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| expect(wrapExpressionsInTemplateConditionals("{{#if false}}body{{/if}}")).toBe("{{#if ${{ false }} }}body{{/if}}"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| it("should leave {{#if false}} unchanged", () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| expect(wrapExpressionsInTemplateConditionals("{{#if false}}body{{/if}}")).toBe("{{#if false}}body{{/if}}"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| it("should wrap {{#if null}}", () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| expect(wrapExpressionsInTemplateConditionals("{{#if null}}body{{/if}}")).toBe("{{#if ${{ null }} }}body{{/if}}"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| it("should leave {{#if null}} unchanged", () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| expect(wrapExpressionsInTemplateConditionals("{{#if null}}body{{/if}}")).toBe("{{#if null}}body{{/if}}"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| describe("boolean/null literals — full wrap→extract pipeline must remain unchanged", () => { | |
| const getExtractedContent = (extracted) => { | |
| if (typeof extracted === "string") { | |
| return extracted; | |
| } | |
| return extracted?.content ?? extracted?.processedContent ?? extracted?.template ?? extracted?.result; | |
| }; | |
| it.each([ | |
| "{{#if true}}body{{/if}}", | |
| "{{#if false}}body{{/if}}", | |
| "{{#if null}}body{{/if}}", | |
| ])("should preserve %s and avoid placeholder insertion", (input) => { | |
| const wrapped = wrapExpressionsInTemplateConditionals(input); | |
| const extracted = extractAndReplacePlaceholders(wrapped); | |
| const output = getExtractedContent(extracted); | |
| expect(output).toBe(input); | |
| expect(output).not.toContain("__GH_AW_"); | |
| expect(JSON.stringify(extracted)).not.toContain("__GH_AW_"); | |
| }); | |
| }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The early-return covers bare
{{#if true}}/false/null, but{{#if ${{ true }} }}(already-wrapped input) will still be converted byextractAndReplacePlaceholders()into{{#if __GH_AW_TRUE__ }}and then fail placeholder validation because there’s no substitution mapping at runtime. Consider also special-casingtrue/false/nullin the extraction step (or unwrapping them back to literals) so wrapped literals don’t produce__GH_AW_TRUE__/__GH_AW_FALSE__/__GH_AW_NULL__placeholders.