Skip to content

execSync is not defined in safeoutputs MCP server, causing create_pull_request to fail #5598

@sozercan

Description

@sozercan

Summary

The create_pull_request safe output fails with the error:

MCP error -32603: Failed to generate patch: execSync is not defined

This appears to be a regression introduced when fixing issue #5584 (GITHUB_SHA not passed to safeoutputs MCP server).

Root Cause

The safeoutputs MCP server code uses execSync in the generateGitPatch and getCurrentBranch functions, but execSync is not properly imported/destructured from child_process.

Looking at the generated code in mcp-server.cjs, I see:

const { execSync } = require("child_process");  // This line appears to be missing
// ...
const branch = execSync("git rev-parse --abbrev-ref HEAD", { ... });

The code uses execSync directly but only execFile is destructured from child_process (used in createShellHandler).

Steps to Reproduce

  1. Create an agentic workflow with create-pull-request safe output
  2. Have the agent make code changes and commit them locally
  3. Call create_pull_request safe output
  4. Observe the MCP error: Failed to generate patch: execSync is not defined

Evidence

From workflow run https://github.com/sozercan/ayna/actions/runs/19955035157:

agent   Execute GitHub Copilot CLI      2025-12-05T06:49:55.6680179Z    MCP error -32603: Failed to generate patch: execSync is not defined
agent   Execute GitHub Copilot CLI      2025-12-05T06:50:07.7160050Z    MCP error -32603: Failed to generate patch: execSync is not defined

The agent attempted to call create_pull_request twice and both failed with the same error.

Safe output recorded by the agent:

{
  "alternatives": "The fix has been committed locally to branch 'fix/test-20251205-064600'. Manually push and create PR.",
  "reason": "The create_pull_request tool is failing with internal error 'execSync is not defined'",
  "tool": "create_pull_request (working)",
  "type": "missing_tool"
}

Expected Behavior

The execSync function should be properly imported from child_process so that create_pull_request can generate git patches and create PRs.

Suggested Fix

Add the missing import at the top of the safeoutputs MCP server code:

const { execSync, execFile } = require("child_process");

Or ensure the bundled/generated code includes this import.

Related Issues

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions