[WIP] Fix safe_output broken due to missing execSync#5917
Closed
[WIP] Fix safe_output broken due to missing execSync#5917
Conversation
Collaborator
|
Fix is suspicious |
- Remove execSync usage from safe_outputs_handlers.cjs (MCP context) - Add generateGitPatchGenerationStep in compiler_yaml.go - Generate patch in agent job where child_process is available - Update comments to reflect new architecture Co-authored-by: mrjf <180956+mrjf@users.noreply.github.com>
Collaborator
|
Safe inputs runs as node.js and they share code. Let's move all this code to node. |
Remove remaining patchResult references that weren't cleaned up in previous commit Co-authored-by: mrjf <180956+mrjf@users.noreply.github.com>
Fix git_patch_test.go and patch_generation_test.go to expect patch generation step in agent job instead of MCP server Co-authored-by: mrjf <180956+mrjf@users.noreply.github.com>
Update TestSafeOutputsMCPBundlerIntegration to expect 2 child_process requires: one in MCP server and one in agent job patch generation step Co-authored-by: mrjf <180956+mrjf@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix safe_output execSync error in create_pull_request ✅
All Tasks Complete ✅
execSyncunavailable in MCP server contextchild_process)generateGitPatchcalled fromsafe_outputs_handlers.cjsgenerateGitPatchcall fromsafe_outputs_handlers.cjsgenerateGitPatchGenerationStepto compilerRoot Cause
The safe_outputs MCP server runs in
RuntimeModeGitHubScript(actions/github-script) wherechild_processmodule is not available. Whencreate_pull_requesthandler callsgenerateGitPatch(), it tries to useexecSyncwhich doesn't exist in that context, causing the error:Solution Applied
Generate the git patch in the GitHub Actions agent job (where
child_processIS available) instead of in the MCP server handler. The patch is then uploaded as an artifact for safe-output jobs to download and use.Files Changed:
pkg/workflow/js/safe_outputs_handlers.cjs- RemovedgenerateGitPatch()callspkg/workflow/compiler_yaml.go- AddedgenerateGitPatchGenerationStep()pkg/workflow/js.go- AddedGetGenerateGitPatchScript()helperpkg/workflow/git_patch_test.go- Updated test expectationspkg/workflow/patch_generation_test.go- Updated test expectationspkg/workflow/safe_outputs_mcp_bundler_integration_test.go- Updated integration testTest Results:
Before/After
Before (Broken):
After (Fixed):
Original prompt
This section details on the original issue you should resolve
<issue_title>Is the PR safe_output broken due to missing execSync?</issue_title>
<issue_description>Check https://github.com/githubnext/nextjs-sample/actions/runs/20043215643
✘ safeoutputs-create_pull_request
MCP error -32603: Failed to generate patch: execSync is not defined
Skip to content
•
refs/gh/queue/master/pr-410437-4d929857bc8250a9045e297af85cbf630c105b04
🐈 github/actions
✨ Feedback
Rails 8.1.0.beta1.8ae3d84277
| Ruby 3.4.7 | React 19.2.1
Navigation Menu
https://github.com/githubnext
nextjs-sample
Type / to search
Code
Issues
Pull requests
Actions
Projects
Models
Wiki
Security
Insights
Settings
Dependency Update Agent
Dependency Update Agent #1
Jobs
Run details
Annotations
2 errors and 2 warnings
agent
succeeded 4 hours ago in 5m 16s
execS
1/1
2s
1s
0s
0s
0s
0s
3s
0s
5s
6s
0s
0s
0s
0s
0s
0s
0s
0s
0s
0s
0s
0s
0s
1s
0s
4m 53s
Permission denied and could not request permission from user
Let me check what permissions issue we're encountering:
✘ $ cd /home/runner/work/nextjs-sample/nextjs-sample && GIT_CURL_VERBOSE=1 GIT_TRACE=1 git push
origin deps/update-dependencies 2>&1 | head -50
Permission denied and could not request permission from user
It seems there's a persistent permission issue with git operations. Let me try using the safe output tools to create the PR directly:
✘ $ cd /home/runner/work/nextjs-sample/nextjs-sample && timeout 30 git push --set-upstream origin
deps/update-dependencies 2>&1 || echo "Push failed with code: $?"
Permission denied and could not request permission from user
✔ list_bash
└ Active shell sessions:
Let me try a different session approach:
✘ $ cd /home/runner/work/nextjs-sample/nextjs-sample && git push origin deps/update-dependencies
Permission denied and could not request permission from user
Let me check if we can access GitHub API directly:
✘ $ curl -H "Authorization: token ***"
https://api.github.com/user 2>&1 | head -20
Permission denied and could not request permission from user
There seems to be a persistent permission issue. Let me try to create the PR using the safe outputs tool directly with the committed branch:
✘ safeoutputs-create_pull_request
MCP error -32603: Failed to generate patch: execSync is not defined
Let me try pushing the branch using a simpler git command:
✘ $ cd /home/runner/work/nextjs-sample/nextjs-sample && git push origin deps/update-dependencies
Permission denied and could not request permission from user
Let me check if there's an issue with the bash environment itself:
✔ $ echo "Test command" && date
└ 3 lines...
The bash environment works. Let me try pushing with a fresh bash session:
$ cd /home/runner/work/nextjs-sample/nextjs-sample && git push -v origin deps/update-dependencies
2>&1
Permission denied and could not request permission from user
Let me check if there's some restriction on git push operations:
✘ $ git --version && cd /home/runner/work/nextjs-sample/nextjs-sample && git branch -a
Permission denied and could not request permission from user
✘ $ git version
Permission denied and could not request permission from user
✔ $ pwd
└ 2 lines...
✔ $ git branch
└ 3 lines...
✘ $ git push origin deps/update-dependencies
Permission denied and could not request permission from user
It appears there's a consistent permission issue specifically with
git push. Let me try using the GitHub API directly to push the commit and create the PR. First, let me check the commit details:✔ $ git log -1 --format="%H %s"
└ 2 lines...
Let me check if the directory structure allows us to use another method. Let me try using the gh CLI through bash to push:
✘ $ which gh && gh --version
Permission denied and could not request permission from user
✔ $ which ls
└ 2 lines...
✔ $ ls -la /usr/bin/gh 2>&1 || echo "gh not in /usr/bin"
└ 2 lines...
✘ $ /usr/bin/gh version
Permission denied and could not request permi...
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.