Format {files} placeholders as inline code in JS template rendering#34011
Conversation
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
files placeholder formatting in JS template renderer{files} placeholders as inline code in JS template rendering
| const invalidFile = files.find(file => file.includes("`")); | ||
| if (invalidFile) { | ||
| throw new Error(`Invalid {files} value: filename "${invalidFile}" contains backticks`); | ||
| } |
There was a problem hiding this comment.
@copilot do not throw, replace with redacted. Handle case where file names have been pre wrapped in back ticks
There was a problem hiding this comment.
Updated in commit 7a8f39b.
{files} rendering now avoids throwing, supports filenames that are already wrapped in backticks, and redacts unsafe entries as `redacted`.
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR updates JS template rendering so {files} placeholders are rendered as inline-code filenames (improving readability of multi-file output) and updates action pin/lock data for docker/metadata-action@v6.
Changes:
- Added special
{files}handling inactions/setup/js/messages_core.cjsto split comma-separated file lists and wrap each filename in inline code. - Added/extended vitest cases around
{files}rendering (including empty input and backtick-containing entries) and file-based template rendering. - Updated action pin/lock data to include
docker/metadata-action@v6and updated the pinned SHA in the release workflow lock.
Show a summary per file
| File | Description |
|---|---|
actions/setup/js/messages_core.cjs |
Implements special {files} placeholder rendering logic. |
actions/setup/js/messages_core.test.cjs |
Adds tests covering {files} formatting behavior and render-from-file path. |
pkg/workflow/data/action_pins.json |
Adds docker/metadata-action@v6 pin entry. |
pkg/actionpins/data/action_pins.json |
Adds docker/metadata-action@v6 pin entry. |
.github/aw/actions-lock.json |
Adds docker/metadata-action@v6 pin entry for GitHub Actions locking. |
.github/workflows/release.lock.yml |
Updates the pinned docker/metadata-action SHA used in the release workflow. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comments suppressed due to low confidence (1)
actions/setup/js/messages_core.cjs:101
- PR description says backtick-containing filenames are rejected and the error includes the offending filename, but the implementation/test suite currently silently replaces those entries with
redacted. Please align either the behavior (throw with a helpful message) or the PR description/tests so consumers know whether this is a hard failure or a soft-sanitize.
if (!normalized || normalized.includes("`")) {
normalized = "redacted";
}
return `\`${normalized}\``;
- Files reviewed: 6/6 changed files
- Comments generated: 2
| if (key === "files") { | ||
| const files = String(value) | ||
| .split(",") | ||
| .map(file => file.trim()) | ||
| .filter(Boolean); |
| it("should specially format files placeholder as backticked filenames", async () => { | ||
| const { renderTemplate } = await import("./messages_core.cjs?" + Date.now()); | ||
| const result = renderTemplate("Changed files: {files}", { files: "a.txt,b/c.md, docs/readme.md " }); | ||
| expect(result).toBe("Changed files: `a.txt`, `b/c.md`, `docs/readme.md`"); | ||
| }); |
|
@copilot move logic into a helper "renderFilesList" and apply to call sites instead |
|
|
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
{files}values were rendered as raw comma-separated text, which made multi-file output harder to scan. This change adds dedicated{files}rendering so filenames are consistently markdown-formatted and unsafe input is rejected.Template rendering behavior
filesexpression inactions/setup/js/messages_core.cjs.filesas a comma-separated list, trims entries, drops empty segments, and renders each filename as an inline code span.Input safety
Coverage updates
actions/setup/js/messages_core.test.cjswith focused cases for:filesinput behavior,renderTemplateFromFile).