Skip to content

Reuse open [aw] <workflow> failed issues before creating new failure reports#34946

Merged
pelikhan merged 7 commits into
mainfrom
copilot/aw-add-deduplication-check
May 26, 2026
Merged

Reuse open [aw] <workflow> failed issues before creating new failure reports#34946
pelikhan merged 7 commits into
mainfrom
copilot/aw-add-deduplication-check

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 26, 2026

Failure reporters were creating a new [aw] <workflow> failed issue on every retry, which produced large volumes of duplicate open issues. This change adds an open-issue dedup check so repeated failures append context to the existing issue instead of filing another one.

  • What changed

    • handle_agent_failure.cjs now reuses an existing open failure issue when the title exactly matches [aw] <workflow> failed.
    • The existing precise metadata match remains the preferred path.
    • If no precise metadata match is found, the reporter falls back to the same-title open issue rather than creating a duplicate.
  • Why this matters

    • Deduplicates repeat failures from retries and reruns.
    • Preserves the stricter metadata-based reuse logic for newer issues while still handling older/open issues that do not carry the newer hidden markers.
  • Test coverage

    • Added/updated focused tests for:
      • exact metadata match reuse
      • reuse of older issues without reusable metadata
      • title-based fallback when branch or PR metadata differs
const existingIssue = await findExistingFailureIssue({
  owner,
  repo,
  issueTitle: `[aw] ${sanitizedWorkflowName} failed`,
  workflowId,
  branch: currentBranch,
  pullRequestNumber: pullRequest?.number,
  failureCategories,
});

// Prefer exact metadata match; otherwise fall back to exact title match
if (existingIssue) {
  await github.rest.issues.createComment({ ... });
} else {
  await github.rest.issues.create({ ... });
}

Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
Copilot AI changed the title [WIP] Add deduplication check before creating new failure issues Reuse open [aw] <workflow> failed issues before creating new failure reports May 26, 2026
Copilot AI requested a review from gh-aw-bot May 26, 2026 14:41
});

for (const item of searchResult.data.items) {
if (!fallbackTitleMatch && item.title === issueTitle) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@copilot xml tags to have precise matching. See helpers for finding matching issues .

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Addressed in 4fc86d5. The failure-issue reuse path now searches by the workflow XML marker in the issue body and only falls back to legacy issues with the matching marker, instead of reusing by raw title match.

Copilot AI and others added 3 commits May 26, 2026 14:58
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI requested a review from pelikhan May 26, 2026 15:06
@pelikhan pelikhan marked this pull request as ready for review May 26, 2026 15:31
Copilot AI review requested due to automatic review settings May 26, 2026 15:31
Copy link
Copy Markdown
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

This PR reduces duplicate [aw] <workflow> failed issues by improving the “find existing failure issue” logic to (1) prefer exact failure-metadata matches and (2) fall back to reusing older (“legacy”) issues identified via workflow marker metadata, including safer GitHub search query construction.

Changes:

  • Added legacy failure-issue reuse detection based on workflow XML marker presence + non-expiration + absence of the precise failure marker.
  • Hardened GitHub search query construction by escaping workflow IDs for safe inclusion in quoted search phrases.
  • Updated/expanded tests to cover legacy reuse behavior and workflow-id escaping in search queries.
Show a summary per file
File Description
actions/setup/js/handle_agent_failure.cjs Adds legacy-issue reuse path, introduces GitHub search phrase escaping, and changes the search strategy to body-marker-based matching.
actions/setup/js/handle_agent_failure.test.cjs Extends tests for legacy-marker reuse and verifies workflow-id escaping in the search query.

Copilot's findings

Tip

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

  • Files reviewed: 2/2 changed files
  • Comments generated: 1

Comment on lines 298 to 305
async function findExistingFailureIssue(options) {
const { owner, repo, issueTitle, workflowId, branch, pullRequestNumber, failureCategories } = options;
const searchQuery = `repo:${owner}/${repo} is:issue is:open label:agentic-workflows in:title "${issueTitle}"`;
const escapedWorkflowId = escapeGitHubSearchPhrase(workflowId);
const searchQuery = `repo:${owner}/${repo} is:issue is:open label:agentic-workflows ` + `"gh-aw-agentic-workflow:" "workflow_id: ${escapedWorkflowId}" in:body`;
const perPage = 100;
/** @type {{number: number, html_url: string} | null} */
let legacyWorkflowMatch = null;

* @returns {boolean} True when the issue belongs to the workflow, is not expired, and
* does not already carry a precise failure marker
*/
function isLegacyReusableFailureIssue(body, workflowId) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@copilot no legacy format support, remove

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Addressed in 47cfaef (cleanup in 39f0c83). The legacy-format reuse path was removed, so failure issues are now reused only on precise gh-aw-failure-issue metadata matches.

Copilot AI and others added 2 commits May 26, 2026 15:58
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI requested a review from pelikhan May 26, 2026 16:01
@pelikhan pelikhan merged commit 2a78a3b into main May 26, 2026
12 checks passed
@pelikhan pelikhan deleted the copilot/aw-add-deduplication-check branch May 26, 2026 16:08
@github-actions github-actions Bot mentioned this pull request May 26, 2026
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.

[aw] Failure reporters: add deduplication check before creating new issues

4 participants