Fix safe-inputs script: runner always returning {"stdout":"","stderr":""}#19493
Fix safe-inputs script: runner always returning {"stdout":"","stderr":""}#19493
script: runner always returning {"stdout":"","stderr":""}#19493Conversation
… main execution block to generated .cjs files Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
script: runner always returning {"stdout":"","stderr":""}
|
@copilot use async await |
…ion block Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
|
@copilot move generated code to a separate file that gets required (safe-inputs-runner.cjs). Add tests , update setup.sh |
…ests, update setup.sh Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Done in b25a2c2. The main execution harness is now in |
|
📰 BREAKING: Smoke Copilot is now investigating this pull request. Sources say the story is developing... |
|
🎬 THE END — Smoke Claude MISSION: ACCOMPLISHED! The hero saves the day! ✨ |
|
✅ All tools validated successfully! Agent Container Smoke Test confirms agent container is ready. |
|
🌑 The shadows whisper... Smoke Codex failed. The oracle requires further meditation... |
|
Commit pushed:
|
Agent Container Tool Check
Result: 12/12 tools available ✅ Overall Status: PASS
|
|
Smoke test by
Overall:
|
There was a problem hiding this comment.
Fix looks correct — the root cause (generated scripts never writing to stdout) is properly addressed by extracting the runner into a shared module. The require.main === module guard is the right pattern. Two minor suggestions: add a timeout guard in the runner, and enhance the generated comment to explain the stdin/stdout protocol.
📰 BREAKING: Report filed by Smoke Copilot
| try { | ||
| const result = await execute(inputs); | ||
| process.stdout.write(JSON.stringify(result)); | ||
| } catch (err) { |
There was a problem hiding this comment.
Consider adding a timeout to the stdin read to prevent hanging if the parent process closes the pipe unexpectedly. Something like process.stdin.resume() with a watchdog timer could guard against zombie processes.
| sb.WriteString("// Run when executed directly (as a subprocess by the MCP handler)\n") | ||
| sb.WriteString("if (require.main === module) {\n") | ||
| sb.WriteString(" require(\"./safe-inputs-runner.cjs\")(execute);\n") | ||
| sb.WriteString("}\n") |
There was a problem hiding this comment.
The generated comment // Run when executed directly (as a subprocess by the MCP handler) is helpful. Consider also noting why this pattern is needed (the MCP handler spawns the script as a subprocess and communicates via stdin/stdout), which would make the generated code self-documenting for anyone reading it.
|
📰 VERDICT: Smoke Copilot has concluded. All systems operational. This is a developing story. 🎤 |
|
Smoke Test Results - Run §22656026286 Core tests (#1–10): Overall: PARTIAL
|
There was a problem hiding this comment.
💥 Automated smoke test review - all systems nominal! The safe-inputs runner refactor looks clean — shared module pattern reduces duplication and the tests cover all edge cases.
💥 [THE END] — Illustrated by Smoke Claude
|
@copilot fix test CI / js (pull_request)Failing after 23s |
|
Hey This PR looks well-aligned with the project's contribution guidelines and code quality standards. Here's a quick summary of what looks great:
The PR is currently in draft state — once any remaining CI checks pass and the draft is marked ready, this looks well-positioned for maintainer review. 🚀
|
…puts-runner.cjs Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Fixed in 6116f5c. The TypeScript error |
There was a problem hiding this comment.
Pull request overview
Fixes safe-inputs JavaScript script: tools always returning empty {"stdout":"","stderr":""} by ensuring generated scripts actually execute when run as a subprocess, via a shared runner harness.
Changes:
- Update JS safe-input tool script generation to include a
require.main === moduleentrypoint that delegates subprocess execution to a shared runner. - Add
actions/setup/js/safe-inputs-runner.cjsand Vitest coverage for stdin parsing, parse errors, and execute errors. - Update setup packaging to copy the new runner into
/opt/gh-aw/safe-inputsand add a changeset entry.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/workflow/safe_inputs_generator.go | Generated JS safe-input scripts now delegate subprocess execution to safe-inputs-runner.cjs. |
| pkg/workflow/safe_inputs_generator_test.go | Extends generator test to assert the new subprocess entrypoint + delegation. |
| actions/setup/js/safe-inputs-runner.cjs | New shared Node subprocess harness: reads stdin JSON, calls execute, writes JSON to stdout. |
| actions/setup/js/safe-inputs-runner.test.cjs | New Vitest coverage for the runner’s stdin parsing and error paths. |
| actions/setup/setup.sh | Ensures safe-inputs-runner.cjs is copied into the safe-inputs runtime directory. |
| .changeset/patch-safe-inputs-runner.md | Declares a patch release note for the safe-inputs runner fix. |
Comments suppressed due to low confidence (2)
actions/setup/js/safe-inputs-runner.cjs:37
- After JSON.parse,
inputscan be a non-object (null/array/primitive) if a caller sends unexpected JSON. The generated scripts/JSDoc assume an object, and downstream destructuring/logic may behave incorrectly. Consider normalizing parsed values so only plain objects are passed toexecute(e.g., if parsed value is not a non-array object, fall back to{}).
let inputs = {};
try {
if (inputJson.trim()) {
inputs = JSON.parse(inputJson.trim());
}
actions/setup/js/safe-inputs-runner.cjs:47
- On
executefailure, the runner writesString(err)and immediately callsprocess.exit(1).String(err)can produce unhelpful output (e.g.,[object Object]) and omits stack traces forErrorobjects, and an immediateprocess.exitcan truncate pending stderr writes. Consider formatting errors similarly to the rest of the codebase (message + optional stack, newline-terminated) and settingprocess.exitCode = 1(or exiting in the write callback) to ensure the error output is flushed before termination.
} catch (err) {
process.stderr.write(String(err));
process.exit(1);
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
generateSafeInputJavaScriptToolScriptgenerates a.cjsthat only exportsexecute()but never calls it when run as subprocessgenerateSafeInputJavaScriptToolScriptinpkg/workflow/safe_inputs_generator.goto add arequire.main === moduleblock that reads stdin, callsexecute(), and writes JSON to stdoutactions/setup/js/safe-inputs-runner.cjs; generated scripts delegate viarequire('./safe-inputs-runner.cjs')(execute)actions/setup/js/safe-inputs-runner.test.cjswith 4 Vitest tests (happy path, empty stdin, JSON parse error, execute error)actions/setup/setup.shto copysafe-inputs-runner.cjsto the safe-inputs directorysafe_inputs_generator_test.goto assertrequire('./safe-inputs-runner.cjs')delegationcatch (e)variable isunknown; usee instanceof Error ? e.message : String(e)guardmake fmt, TypeScript check, Vitest testsOriginal prompt
safe-inputswithscript:always returns{"stdout":"","stderr":""}#19489🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.
✨ PR Review Safe Output Test - Run 22656026286