Add diagnostic logging to interpolate_prompt.cjs#14834
Conversation
…ng issues 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
Adds extensive diagnostic logging to actions/setup/js/interpolate_prompt.cjs to help troubleshoot prompt rendering (runtime imports, variable interpolation, and {{#if}} template conditionals) during workflow execution.
Changes:
- Adds detailed
core.info()logging throughout variable interpolation and template rendering (counts, previews, length deltas). - Adds step/phase headers and enhanced error logging in
main(). - Updates
interpolate_prompt_additional.test.cjsto mockglobal.corefor the new logging calls.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| actions/setup/js/interpolate_prompt.cjs | Adds comprehensive runtime logging across interpolation, template rendering, and main execution steps. |
| actions/setup/js/interpolate_prompt_additional.test.cjs | Mocks global.core to support new core.info() calls during extracted-function testing. |
Comments suppressed due to low confidence (4)
actions/setup/js/interpolate_prompt.cjs:204
- The variable interpolation step logs previews of every
GH_AW_EXPR_*value. If any expression resolves to a secret (e.g.,secrets.*, tokens), this will print it into the Actions log. Recommend logging only variable names/counts by default and gating value previews behind a debug flag, or applying redaction (e.g., mask patterns /core.setSecret).
core.info(`Found ${varCount} expression variable(s) to interpolate:`);
for (const [key, value] of Object.entries(variables)) {
const preview = value.substring(0, 60);
core.info(` ${key}: ${preview}${value.length > 60 ? "..." : ""}`);
}
actions/setup/js/interpolate_prompt.cjs:78
renderMarkdownTemplate()logs body previews for both block and inline conditionals. Since conditional bodies can contain interpolated expression results or runtime-imported content, these previews risk leaking sensitive data to logs. Consider removing/redacting body previews by default and gating them behind an explicit debug flag /core.debug.
const bodyPreview = body.substring(0, 60).replace(/\n/g, "\\n");
core.info(`[renderMarkdownTemplate] Block ${blockCount}: condition="${condTrimmed}" -> ${truthyResult ? "KEEP" : "REMOVE"}`);
core.info(`[renderMarkdownTemplate] Body preview: "${bodyPreview}${body.length > 60 ? "..." : ""}"`);
actions/setup/js/interpolate_prompt.cjs:34
interpolateVariables()logs a preview of each variable value being inserted. SinceGH_AW_EXPR_*values can come from evaluated expressions (and may include secrets/tokens depending on workflow usage), printing even truncated values to logs can leak sensitive data. Consider logging only variable names/counts by default and gating/redacting value previews behind a debug flag.
if (matches > 0) {
core.info(`[interpolateVariables] Replacing ${varName} (${matches} occurrence(s))`);
core.info(`[interpolateVariables] Value: ${value.substring(0, 100)}${value.length > 100 ? "..." : ""}`);
result = result.replace(pattern, value);
actions/setup/js/interpolate_prompt.cjs:246
[main] Last 200 characters: ...logs a tail preview of the processed prompt. This can expose sensitive prompt content (including runtime-imported data) in workflow logs. Recommend removing/redacting content previews by default and gating behind an explicit debug flag /core.debug.
core.info(`Last 200 characters: ${content.substring(Math.max(0, content.length - 200)).replace(/\n/g, "\\n")}`);
core.info("========================================");
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| for (const [varName, value] of Object.entries(variables)) { | ||
| const pattern = new RegExp(`\\$\\{${varName}\\}`, "g"); | ||
| result = result.replace(pattern, value); | ||
| const matches = (content.match(pattern) || []).length; | ||
|
|
||
| if (matches > 0) { | ||
| core.info(`[interpolateVariables] Replacing ${varName} (${matches} occurrence(s))`); | ||
| core.info(`[interpolateVariables] Value: ${value.substring(0, 100)}${value.length > 100 ? "..." : ""}`); | ||
| result = result.replace(pattern, value); | ||
| totalReplacements += matches; | ||
| } else { | ||
| core.info(`[interpolateVariables] Variable ${varName} not found in content (unused)`); | ||
| } |
There was a problem hiding this comment.
interpolateVariables() now only runs result.replace() when matches > 0, but matches is computed from the original content. If an earlier replacement introduces a new ${VAR} placeholder (e.g., a variable value contains another placeholder), later variables may be incorrectly treated as “unused” and skipped, leaving placeholders un-interpolated. Compute matches from result (current working string) and/or perform the replacement unconditionally to preserve previous behavior.
| const originalLength = content.length; | ||
| core.info(`[main] Original content length: ${originalLength} characters`); | ||
| core.info(`[main] First 200 characters: ${content.substring(0, 200).replace(/\n/g, "\\n")}`); |
There was a problem hiding this comment.
core.info logs the first 200 characters of the prompt ([main] First 200 characters: ...). This can leak sensitive data into workflow logs (prompt may include user content or runtime-imported data). Consider removing content previews by default, redacting, or gating behind an explicit debug flag / core.debug.
This issue also appears in the following locations of the same file:
- line 200
- line 74
- line 31
- line 245
|
📰 BREAKING: Smoke Copilot is now investigating this pull request. Sources say the story is developing... |
|
🧪 Smoke Project is now testing project operations... |
|
✨ The prophecy is fulfilled... Smoke Codex has completed its mystical journey. The stars align. 🌟 |
|
✅ Changeset Generator completed successfully! |
|
🎬 THE END — Smoke Claude MISSION: ACCOMPLISHED! The hero saves the day! ✨ |
Agent Container Tool Check
Result: 11/12 tools available Note: .NET runtime (dotnet) is not available in the agent container. All other core development tools are present and functional.
|
|
✅ Smoke Project completed successfully. All project operations validated. |
|
PR titles: Fix error location, double prefix, and confusing paths for nested safe-outputs validation errors; Add compile-time validation for dangerous property names in expressions
|
|
@pelikhan PR #14835: chore: revert action pins and recompile dependabot-burner workflow ✅ GitHub MCP Overall Status: PASS ✅
|
|
📰 VERDICT: Smoke Copilot has concluded. All systems operational. This is a developing story. 🎤 |
Adds comprehensive logging to
interpolate_prompt.cjsto diagnose prompt rendering issues during workflow execution.Changes
Logging coverage:
Implementation:
core.info()directly, assuming core is globally availableglobal.corewith vitest functions[functionName]prefixes for filteringExample Output
Enables runtime diagnosis of variable replacement failures, conditional evaluation errors, and unexpected content transformations.
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.
Add diagnostic logging to interpolate_prompt.cjs
Adds comprehensive logging to
interpolate_prompt.cjsto diagnose prompt rendering issues during workflow execution.Logging coverage:
Implementation:
core.info()directly, assuming core is globally availableglobal.corewith vitest functions[functionName]prefixes for filteringExample Output
Enables runtime diagnosis of variable replacement failures, conditional evaluation errors, and unexpected content transformations.
Original prompt
✨ Let Copilot coding agent [set things up for you](https://github.com/github/gh-aw/issues/new?title=✨+Set+up+Copilot+instructions&body=Configure%20instructions%20for%20this%20repository%20as%20documented%20in%20%5BBest%20practices%20for%20Copilot%20coding%20agent%20in%20your%20repository%5D%28(gh.io/redacted) — coding agent works faster and does higher quality work when set up for your repo.
Changeset
interpolate_prompt.cjsto make prompt rendering issues easier to diagnose at runtime.