Skip to content

Add diagnostic logging to interpolate_prompt.cjs - #14834

Merged
pelikhan merged 3 commits into
mainfrom
copilot/fix-9919-1036865607-5daf8dee-e779-48be-9566-2a634132a0fd
Feb 10, 2026
Merged

Add diagnostic logging to interpolate_prompt.cjs#14834
pelikhan merged 3 commits into
mainfrom
copilot/fix-9919-1036865607-5daf8dee-e779-48be-9566-2a634132a0fd

Conversation

CopilotAI commented Feb 10, 2026

Copy link
Copy Markdown
Contributor

Adds comprehensive logging to interpolate_prompt.cjs to diagnose prompt rendering issues during workflow execution.

Changes

Logging coverage:

  • Variable interpolation: replacement counts, values (truncated), unused variables
  • Template conditionals: block/inline counts, per-conditional evaluation (condition text, decision, body preview)
  • Content transformations: length tracking across all processing steps
  • Error handling: error type, message, and stack trace

Implementation:

  • Uses core.info() directly, assuming core is globally available
  • Test files mock global.core with vitest functions
  • 68 logging statements with [functionName] prefixes for filtering
  • Structured output with section headers for each processing phase

Example Output

[renderMarkdownTemplate] Block 1: condition="github.event.issue.number" -> KEEP
[renderMarkdownTemplate] Body preview: "## Issue Details\nThis section shows..."
[renderMarkdownTemplate] Action: Keeping body with leading newline=true

Enables runtime diagnosis of variable replacement failures, conditional evaluation errors, and unexpected content transformations.

Original prompt

Add extensive logging to interpolate prompt JavaScript to understand rendering issues.

const { main } = require('/opt/gh-aw/actions/interpolate_prompt.cjs');


✨ 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.cjs to diagnose prompt rendering issues during workflow execution.

Logging coverage:

  • Variable interpolation: replacement counts, values (truncated), unused variables
  • Template conditionals: block/inline counts, per-conditional evaluation (condition text, decision, body preview)
  • Content transformations: length tracking across all processing steps
  • Error handling: error type, message, and stack trace

Implementation:

  • Uses core.info() directly, assuming core is globally available
  • Test files mock global.core with vitest functions
  • 68 logging statements with [functionName] prefixes for filtering
  • Structured output with section headers for each processing phase

Example Output

[renderMarkdownTemplate] Block 1: condition="github.event.issue.number" -> KEEP
[renderMarkdownTemplate] Body preview: "## Issue Details\nThis section shows..."
[renderMarkdownTemplate] Action: Keeping body with leading newline=true

Enables runtime diagnosis of variable replacement failures, conditional evaluation errors, and unexpected content transformations.

Original prompt

Add extensive logging to interpolate prompt JavaScript to understand rendering issues.

const { main } = require('/opt/gh-aw/actions/interpolate_prompt.cjs');


✨ 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

  • Type: patch
  • Description: Adds diagnostic logging to interpolate_prompt.cjs to make prompt rendering issues easier to diagnose at runtime.

Generated by Changeset Generator

…ng issues
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>

@pelikhanpelikhan left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@copilot core should be defined globally always. Mock in tests or pass as optional parameter.

CopilotAI changed the title [WIP] Add extensive logging to interpolate prompt JavaScript to understand rendering issues. const { main } = require('/opt/gh-aw/actions/interpolate_prompt.cjs');Add diagnostic logging to interpolate_prompt.cjsFeb 10, 2026
CopilotAI requested a review from pelikhanFebruary 10, 2026 20:48
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>

CopilotAI commented Feb 10, 2026

Copy link
Copy Markdown
ContributorAuthor

@copilot core should be defined globally always. Mock in tests or pass as optional parameter.

Updated in commit 9a87f68. Removed all typeof core !== 'undefined' checks and added global.core mock to the additional test file.

@pelikhan
pelikhan marked this pull request as ready for review February 10, 2026 20:56
CopilotAI review requested due to automatic review settings February 10, 2026 20:56

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.cjs to mock global.core for the new logging calls.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

FileDescription
actions/setup/js/interpolate_prompt.cjsAdds comprehensive runtime logging across interpolation, template rendering, and main execution steps.
actions/setup/js/interpolate_prompt_additional.test.cjsMocks 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. Since GH_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.

Comment on lines 27 to +38
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)`);
}

CopilotAIFeb 10, 2026

Copy link

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
Comment on lines +160 to +162
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")}`);

CopilotAIFeb 10, 2026

Copy link

Choose a reason for hiding this comment

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

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

Copilot uses AI. Check for mistakes.
@github-actions

Copy link
Copy Markdown
Contributor

📰 BREAKING: Smoke Copilot is now investigating this pull request. Sources say the story is developing...

@github-actions

Copy link
Copy Markdown
Contributor

🧪 Smoke Project is now testing project operations...

@github-actions

github-actionsBot commented Feb 10, 2026

Copy link
Copy Markdown
Contributor

✨ The prophecy is fulfilled... Smoke Codex has completed its mystical journey. The stars align. 🌟

@github-actions

github-actionsBot commented Feb 10, 2026

Copy link
Copy Markdown
Contributor

Changeset Generator completed successfully!

@github-actions

github-actionsBot commented Feb 10, 2026

Copy link
Copy Markdown
Contributor

🎬 THE ENDSmoke ClaudeMISSION: ACCOMPLISHED! The hero saves the day! ✨

@github-actions

Copy link
Copy Markdown
Contributor

Agent Container Tool Check

ToolStatusVersion
bash5.2.21(1)-release
shok
git2.52.0
jqjq-1.7
yqv4.52.2
curl8.x
gh2.86.0
nodev20.20.0
python3Python 3.x
gogo1.24.12
javaAvailable
dotnetnot found

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.

AI generated by Agent Container Smoke Test

@pelikhan
pelikhan merged commit dced9cb into mainFeb 10, 2026
164 checks passed
@pelikhan
pelikhan deleted the copilot/fix-9919-1036865607-5daf8dee-e779-48be-9566-2a634132a0fd branch February 10, 2026 21:07
@github-actions

Copy link
Copy Markdown
Contributor

Smoke Project completed successfully. All project operations validated.

@github-actions

Copy link
Copy Markdown
Contributor

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
GitHub MCP (2 merged PRs): ✅
Serena activate + find_symbol: ✅
Playwright title check: ✅
File write: ✅
Bash cat verify: ✅
Build (make build): ✅
Overall: PASS

AI generated by Smoke Codex

@github-actions

Copy link
Copy Markdown
Contributor

@pelikhan@Copilot

PR #14835: chore: revert action pins and recompile dependabot-burner workflow
PR #14834: Add diagnostic logging to interpolate_prompt.cjs

✅ GitHub MCP
✅ Safe Inputs GH CLI
✅ Serena MCP
✅ Playwright
✅ File Writing
✅ Bash Tool
✅ Discussion Interaction
✅ Build gh-aw
✅ Workflow Dispatch

Overall Status: PASS

AI generated by Smoke Copilot

@github-actions

Copy link
Copy Markdown
Contributor

📰 VERDICT: Smoke Copilot has concluded. All systems operational. This is a developing story. 🎤

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@pelikhan