Skip to content

🔗 Include target PR link in code push failure context#18058

Merged
dsyme merged 8 commits intomainfrom
err
Feb 24, 2026
Merged

🔗 Include target PR link in code push failure context#18058
dsyme merged 8 commits intomainfrom
err

Conversation

@dsyme
Copy link
Contributor

@dsyme dsyme commented Feb 24, 2026

Summary

  • Adds optional pullRequest parameter to buildCodePushFailureContext to accept PR info
  • When a PR is available, appends a Target Pull Request link to the code push failure message for better traceability
  • Passes the pullRequest object through both call sites in main()

Copilot AI review requested due to automatic review settings February 24, 2026 04:47
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds PR traceability to code push failure reporting by optionally including a link to the target pull request in the generated failure context.

Changes:

  • Extend buildCodePushFailureContext to accept an optional pullRequest object.
  • Append a “Target Pull Request” markdown link when PR info is available.
  • Thread the pullRequest object through both main() call sites that build the code-push failure context.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions
Copy link
Contributor

Hey @dsyme 👋 — thanks for the work on improving failure diagnostics! Adding the target PR link and merge-state details to code push failure messages is a genuinely useful improvement for traceability.

That said, there are a couple of things that need to be addressed before this can be considered for merging:

❌ Process Violation: Traditional PRs Are Not Enabled

The repository's CONTRIBUTING.md is explicit:

🚫 Traditional Pull Requests Are Not Enabled: You cannot create pull requests directly. Instead, you create detailed agentic plans in issues, and GitHub Copilot Agent will create and implement the PR for you after maintainer approval.

This PR was opened directly (not by GitHub Copilot Agent), which bypasses the required agentic workflow. The correct path is:

  1. Open an issue with a detailed agentic plan describing the changes (root cause analysis, implementation steps, test cases).
  2. Wait for maintainer approval — a maintainer assigns the issue to Copilot Agent.
  3. The agent creates and implements the PR automatically.

🧪 Missing Tests

The diff modifies actions/setup/js/handle_agent_failure.cjs but includes no corresponding test updates. The new buildCodePushFailureContext parameter and PR-state diagnostic logic should be covered by tests.


If you'd like a hand getting this contribution across the finish line through the proper agentic process, you can open an issue with the plan below and assign this prompt to your coding agent:

Implement the following improvement to `actions/setup/js/handle_agent_failure.cjs`:

## Goal
Include the target PR link and PR state diagnostics in code push failure context messages to improve traceability when agent workflows fail.

## Changes Required

### 1. Extend `findPullRequestForCurrentBranch` return type
After finding the PR via search, make a second call to `github.rest.pulls.get` to fetch detailed PR info. Return the extended object:
- `number`, `html_url` (existing)
- `head_sha` (from `detailedPR.data.head.sha`)
- `mergeable` (from `detailedPR.data.mergeable`)
- `mergeable_state` (from `detailedPR.data.mergeable_state`, default `"unknown"`)
- `updated_at` (from `detailedPR.data.updated_at`)
Include a try/catch fallback that returns the basic info with empty/null values if the detailed fetch fails.

### 2. Update `buildCodePushFailureContext(codePushFailureErrors, pullRequest = null)`
Add an optional `pullRequest` parameter. When provided:
- Append `\n\n**Target Pull Request:** [#N](url)` after the failure header.
- Compute PR state diagnostics:
  - `mergeable === false` or `mergeable_state === "dirty"` → merge conflict warning
  - `mergeable_state === "blocked"` → blocked status warning
  - `mergeable_state === "behind"` → behind base branch warning
  - Compare `GITHUB_SHA` env var to `pullRequest.head_sha` → branch-updated warning
  - Include head SHA, workflow SHA, and mergeable_state for debugging
- Append a **PR State at Push Time:** section listing all diagnostics.

### 3. Pass `pullRequest` through all `buildCodePushFailureContext` call sites in `main()`

### 4. Also append PR link to `repoMemoryValidationContext` and `missingSafeOutputsContext` blocks in `main()` when a PR is available.

### 5. Write tests
Add or update tests in the test file adjacent to `handle_agent_failure.cjs` covering:
- `buildCodePushFailureContext` with no PR (existing behavior unchanged)
- `buildCodePushFailureContext` with a PR that has merge conflicts (`mergeable === false`)
- `buildCodePushFailureContext` with a PR in `dirty` state
- `buildCodePushFailureContext` with a PR in `blocked` state
- `buildCodePushFailureContext` where the workflow SHA differs from the PR head SHA
- `buildCodePushFailureContext` with a PR in a clean, up-to-date state (no diagnostic lines)

Run `make agent-finish` before completing to validate all checks pass.

Generated by Contribution Check

@dsyme dsyme merged commit 405eafc into main Feb 24, 2026
43 checks passed
@dsyme dsyme deleted the err branch February 24, 2026 13:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants