Skip to content

fix: prevent duplicate [aw] No-Op Runs issues on transient search failure#19613

Merged
pelikhan merged 2 commits intomainfrom
copilot/fix-transient-search-failure
Mar 4, 2026
Merged

fix: prevent duplicate [aw] No-Op Runs issues on transient search failure#19613
pelikhan merged 2 commits intomainfrom
copilot/fix-transient-search-failure

Conversation

Copy link
Contributor

Copilot AI commented Mar 4, 2026

A transient API error (rate limit, network blip) during the issue search in ensureAgentRunsIssue() was silently swallowed, causing execution to fall through to issues.create — potentially producing duplicate [aw] No-Op Runs tracking issues when one already existed.

Changes

  • handle_noop_message.cjs — replace core.warning + fall-through in the search catch block with a throw, so a failed search aborts rather than creates:
// Before: swallowed error, fell through to create
} catch (error) {
  core.warning(`Error searching for no-op runs issue: ${getErrorMessage(error)}`);
}
// create path always reached on both "not found" and "search error"

// After: propagates error to caller
} catch (error) {
  throw new Error(`Failed to search for existing no-op runs issue: ${getErrorMessage(error)}`);
}
// create path only reached when search succeeded with zero results

The main() caller already wraps ensureAgentRunsIssue() in a try/catch that logs a warning and returns early, so this change slots cleanly into existing error handling with no behavior change for the happy path.

  • handle_noop_message.test.cjs — adds a test asserting that a search API rejection does not trigger issues.create or issues.createComment.
Original prompt

This section details on the original issue you should resolve

<issue_title>handle_noop_message: transient search failure falls through to create and can produce duplicate [aw] No-Op Runs issues</issue_title>
<issue_description>## Context

Observed while running gh-aw v0.52.1 in production in samuelkahessay/prd-to-prod — a parallel agentic pipeline with concurrent agent work. Still present on current main at 6502173c8 (v0.53.1-2-g6502173c8).

Location

actions/setup/js/handle_noop_message.cjs — lines 24–63, ensureAgentRunsIssue()

Problem

The search for an existing [aw] No-Op Runs issue catches errors and falls through to the create path without distinguishing "search returned zero results" from "search threw an error":

// Lines 24-41
try {
  const { data } = await github.rest.search.issuesAndPullRequests({
    q: searchQuery,
    per_page: 1,
  });

  if (data.total_count > 0) {
    // ... return existing issue
  }
} catch (error) {
  core.warning(`Error searching for no-op runs issue: ${getErrorMessage(error)}`);
}

// Falls through to create on BOTH "not found" AND "search failed"
const { data: newIssue } = await github.rest.issues.create({ ... });

A transient API failure (rate limit, network blip) can create a duplicate [aw] No-Op Runs tracking issue when one already exists. Over time this fragments the no-op run history across multiple issues.

The caller already expects ensureAgentRunsIssue() to throw and abort posting if issue setup fails (main() lines 133–138), so treating a search failure as "not found" is the wrong behavior here.

Proposed fix

Distinguish between "search returned zero results" and "search threw an error." On search error, either retry or propagate a search-specific error rather than falling through to create:

let existingIssue = null;
try {
  const { data } = await github.rest.search.issuesAndPullRequests({ ... });
  if (data.total_count > 0) {
    existingIssue = data.items[0];
  }
} catch (error) {
  throw new Error(
    `Failed to search for existing no-op runs issue: ${getErrorMessage(error)}`
  );
}

if (existingIssue) {
  return { number: existingIssue.number, node_id: existingIssue.node_id };
}

// Only create if search succeeded and returned zero results

Environment

  • Observed in production: v0.52.1
  • Still present on: main at 6502173c8 (v0.53.1-2-g6502173c8)
  • Pipeline: Parallel agentic workflow (decompose → dispatch → implement → review → merge)
  • Repo: samuelkahessay/prd-to-prod</issue_description>

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.

…te no-op issues

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix transient search failure in handle_noop_message fix: prevent duplicate [aw] No-Op Runs issues on transient search failure Mar 4, 2026
@pelikhan pelikhan marked this pull request as ready for review March 4, 2026 15:18
Copilot AI review requested due to automatic review settings March 4, 2026 15:18
@pelikhan pelikhan merged commit 761b4c4 into main Mar 4, 2026
102 checks passed
@pelikhan pelikhan deleted the copilot/fix-transient-search-failure branch March 4, 2026 15:18
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

Prevents duplicate [aw] No-Op Runs issues by aborting issue creation when the “search for existing issue” call fails (e.g., transient API/rate-limit/network errors), instead of silently falling through to the create path.

Changes:

  • Update ensureAgentRunsIssue() to throw on search failures rather than warning and continuing to create.
  • Add a regression test ensuring a rejected search does not call issues.create or issues.createComment.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
actions/setup/js/handle_noop_message.cjs Propagates search failures so the caller can abort before creating a potentially-duplicate tracking issue.
actions/setup/js/handle_noop_message.test.cjs Adds test coverage for “search throws” behavior to ensure no issue/comment is created.
Comments suppressed due to low confidence (1)

actions/setup/js/handle_noop_message.cjs:40

  • When rethrowing the search failure, this wraps the original exception and loses its stack/metadata. Since this repo runs on modern Node versions, consider using the Error cause option (or otherwise preserving the original error) so logs/debugging retain the underlying error details.
    throw new Error(`Failed to search for existing no-op runs issue: ${getErrorMessage(error)}`);

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

You can also share your feedback on Copilot code review. Take the survey.

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.

handle_noop_message: transient search failure falls through to create and can produce duplicate [aw] No-Op Runs issues

3 participants