Skip to content

apply_samples.cjs crashes parsing stdout that contains '[debug] ...' lines (create_pull_request sample replay) #37526

Description

@dsyme

Summary

apply_samples.cjs crashes with SyntaxError: Unexpected token 'd', "[debug] Exe"... is not valid JSON while replaying a sample for the create_pull_request safe-output tool. The crash terminates the agent step with exit code 1.

Root cause: sendJsonRpc (apply_samples.cjs:178) assumes the MCP server's stdout contains only JSON-RPC frames, but the safe-outputs MCP server interleaves [debug] … lines on stdout when generating a PR patch/bundle.

Reproduction

Workflow test-copilot-create-pull-request in githubnext/gh-aw-test compiled with --use-samples; sample replays a single create_pull_request call. Trigger via gh aw run test-copilot-create-pull-request.

Observed

Failing run: https://github.com/githubnext/gh-aw-test/actions/runs/27076897189

Truncated log:

[safeoutputs] Pinned branch 'gh-aw-sample-copilot-multi-commit' to SHA …
[safeoutputs] Generating patch for create_pull_request with branch: …
[error] Git command failed: git show-ref --verify --quiet refs/remotes/origin/gh-aw-sample-copilot-multi-commit
[error] Exit status: 1
[safeoutputs] Bundle generated successfully: /tmp/gh-aw/aw-gh-aw-sample-copilot-multi-commit.bundle (572 bytes)
[safeoutputs] send: {"jsonrpc":"2.0","id":2,"result":{…,"isError":false}}
[error] SyntaxError: Unexpected token 'd', "[debug] Exe"... is not valid JSON
    at JSON.parse (<anonymous>)
    at sendJsonRpc (/home/runner/work/_temp/gh-aw/actions/apply_samples.cjs:178:15)
    at process.processTicksAndRejections (node:internal/process/task_queues:103:5)
    at async main (/home/runner/work/_temp/gh-aw/actions/apply_samples.cjs:303:23)
##[error]Process completed with exit code 1.

The [debug] Executing… line is emitted by the MCP server's git/patch code path on stdout instead of stderr, and the apply_samples client tries to JSON.parse it.

Impact

Blocks all sample-based testing of:

  • test-copilot-create-pull-request (+ nosandbox, siderepo variants)
  • test-copilot-create-two-pull-requests (+ variants)
  • test-copilot-push-to-pull-request-branch (+ variants)
  • test-claude-* and test-codex-* PR-creating equivalents

i.e. ~9 e2e tests in githubnext/gh-aw-test cannot pass with --use-samples until this is fixed.

Suggested fix

Either:

  1. Route all non-JSON-RPC logging from the safe-outputs MCP server (debug, git command echo, patch progress) to stderr only, so the JSON-RPC parser on stdout never sees it.
  2. Make sendJsonRpc line-aware: split on \n and only JSON.parse lines that begin with {.

(1) is the cleaner fix; (2) is defensive.

Environment

  • gh-aw main (commit d25afa6 as of 2026-06-06)
  • Hosted runner ubuntu-24.04
  • Compiled with --use-samples

Metadata

Metadata

Assignees

Labels

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions