Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 11, 2026

The push_to_pull_request_branch handler with target: "*" validated patches but never executed git operations (checkout, apply, commit, push). The handler failed to extract the PR number from agent output, returning early with "Pull request number is required but not found".

Changes

Field name mismatch in actions/setup/js/push_to_pull_request_branch.cjs:

  } else if (target === "*") {
-   if (message.pull_number) {
-     pullNumber = parseInt(message.pull_number, 10);
+   if (message.pull_request_number) {
+     pullNumber = parseInt(message.pull_request_number, 10);
    }
  }

The handler was reading pull_number instead of pull_request_number, which is:

  • Defined in schemas/agent-output.json
  • Used by all other PR handlers (add_reviewer, close_pull_request, mark_pull_request_as_ready_for_review)
  • Expected by safe_output_helpers.cjs

This allows agents to push changes to any PR when using target: "*" in workflow_dispatch triggers.

Original prompt

This section details on the original issue you should resolve

<issue_title>push_to_pull_request_branch with target: '*' does not push changes when triggered via workflow_dispatch</issue_title>
<issue_description>## Bug Description

When using push_to_pull_request_branch with target: "*" configuration in a workflow triggered by workflow_dispatch, the handler validates the patch but does not actually perform any git operations (checkout, apply patch, commit, push). The handler reports success despite no changes being pushed.

Environment

  • gh-aw version: latest (as of 2026-01-11)
  • Trigger: workflow_dispatch
  • Engine: copilot with claude-opus-4.5

Workflow Configuration

on:
  workflow_dispatch:
  schedule: every 4h

safe-outputs:
  push-to-pull-request-branch:
    target: "*"  # Allow agent to specify any PR
  create-pull-request:
    title-prefix: "[workflow-study] "
    labels: [gh-aw-research]

Agent Output

The agent correctly outputs the tool call with all required parameters:

{
  "message": "Push committed changes",
  "pull_request_number": 4,
  "type": "push_to_pull_request_branch",
  "branch": "main-61af580be917ea9d"
}

Expected Behavior

The safe_outputs job should:

  1. Read pull_request_number: 4 from agent output
  2. Checkout the PR branch main-61af580be917ea9d
  3. Apply the 30KB patch file
  4. Commit and push to the PR branch

Actual Behavior

From the workflow logs:

safe_outputs    Checkout repository     Switched to a new branch 'main'
safe_outputs    Checkout repository     branch 'main' set up to track 'origin/main'
...
safe_outputs    Process Safe Outputs    Processing message 1/2: push_to_pull_request_branch
safe_outputs    Process Safe Outputs    Patch size: 30 KB (maximum allowed: 1024 KB)
safe_outputs    Process Safe Outputs    Patch size validation passed
safe_outputs    Process Safe Outputs    Patch content validation passed
safe_outputs    Process Safe Outputs    Target configuration: *
safe_outputs    Process Safe Outputs    ✓ Message 1 (push_to_pull_request_branch) completed successfully

Key observations:

  1. Checkout goes to main, not the target PR branch
  2. Only validation steps are logged, no git operations (apply, commit, push)
  3. Time elapsed: 0.0016 seconds from "Processing" to "completed successfully" - too fast for actual git operations
  4. No commit appears on the PR branch

In contrast, add_comment (message 2) correctly resolves and targets PR #4:

safe_outputs    Process Safe Outputs    Resolved target issue githubnext/gh-aw#4 (target config: *)
safe_outputs    Process Safe Outputs    Adding comment to issue/PR githubnext/gh-aw#4 in owner/repo
safe_outputs    Process Safe Outputs    Created comment: https://github.com/...

Workaround

Currently using create_pull_request instead, which creates a new PR each time. This works but is not ideal for iterative workflows.

Root Cause Hypothesis

The push_to_pull_request_branch handler appears to:

  • Correctly validate patch size and content
  • Correctly read target: "*" configuration
  • But not implement the logic to:
    • Checkout the specified PR branch (from pull_request_number or branch parameter)
    • Apply the patch
    • Commit and push

The handler may only be fully implemented for the target: "triggering" case (when workflow is triggered by a PR event), and the target: "*" code path may be incomplete.

Reproduction Steps

  1. Create a workflow with:
    • on: workflow_dispatch
    • safe-outputs.push-to-pull-request-branch.target: "*"
  2. Have the agent create files and call push_to_pull_request_branch with a valid pull_request_number
  3. Observe that the handler reports success but no commit appears on the PR

Related Run

Comments on the Issue (you are @copilot in this section)


💡 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.

…equest_number

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix push_to_pull_request_branch with target '*' not working Fix push_to_pull_request_branch with target: '*' reading wrong field name Jan 11, 2026
Copilot AI requested a review from pelikhan January 11, 2026 19:36
@pelikhan pelikhan marked this pull request as ready for review January 11, 2026 19:58
@pelikhan pelikhan merged commit 76afef3 into main Jan 11, 2026
@pelikhan pelikhan deleted the copilot/fix-push-to-pull-request branch January 11, 2026 19:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants