Skip to content

Conversation

@philprime
Copy link
Member

The workflow was creating duplicate issues when multiple trigger events (opened, edited, synchronize, etc.) fired in quick succession. Both workflow runs would check the PR simultaneously, find no issue reference, and each create a new issue.

Added a check to search for existing issues created by this automation before creating a new one. The workflow now searches for open issues that contain the PR URL and were created by github-actions bot, preventing duplicate issue creation.

Fixes the issue where PR #6386 had two issues created (#6499 and #6500).

#skip-changelog

The workflow was creating duplicate issues when multiple trigger events
(opened, edited, synchronize, etc.) fired in quick succession. Both
workflow runs would check the PR simultaneously, find no issue reference,
and each create a new issue.

Added a check to search for existing issues created by this automation
before creating a new one. The workflow now searches for open issues that
contain the PR URL and were created by github-actions bot, preventing
duplicate issue creation.

Fixes the issue where PR #6386 had two issues created (#6499 and #6500).
@cursor
Copy link

cursor bot commented Oct 23, 2025

Bug: Search Filter Fails to Detect Issues

The search query's author:app/github-actions filter prevents detecting existing issues. Issues created by the workflow using GITHUB_TOKEN are typically attributed to github-actions[bot] or the token's user, not app/github-actions. This results in duplicate issues being created.

Fix in Cursor Fix in Web

@philprime philprime marked this pull request as draft October 23, 2025 13:50
Copy link
Contributor

@stephanie-anderson stephanie-anderson left a comment

Choose a reason for hiding this comment

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

nice, thanks!

@philprime philprime marked this pull request as ready for review October 23, 2025 13:53
@philprime
Copy link
Member Author

@sentry review

@cursor
Copy link

cursor bot commented Oct 23, 2025

Bug: Search Fails to Filter by Bot Creator

The search query for existing issues doesn't filter by the github-actions bot creator. This allows it to match any open issue mentioning the PR URL, even if manually created, causing the workflow to incorrectly skip creating a new tracking issue. This defeats the automation's goal of ensuring all unreferenced PRs get a dedicated issue.

Fix in Cursor Fix in Web

Comment on lines +73 to +75
const existingIssuesResponse = await github.rest.search.issuesAndPullRequests({
q: `repo:${context.repo.owner}/${context.repo.repo} is:issue is:open "${prUrl}" in:title in:body`,
});

Choose a reason for hiding this comment

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

Bug: The GitHub issue search query is missing an <code>author</code> filter, causing it to incorrectly match issues created by any user, not just the automation bot.
Severity: HIGH | Confidence: 1.00

🔍 Detailed Analysis

The GitHub API search query in `existingIssuesResponse` is intended to find duplicate issues created by the automation. However, it is missing an `author` filter to limit the search to issues created by the `github-actions` bot. Consequently, the search will match any open issue that contains the pull request URL, regardless of who created it. If a user manually creates an issue and references the PR URL, the automation will incorrectly determine an issue already exists and will skip creating its own necessary tracking issue.

💡 Suggested Fix

Update the search query q to include an author filter to only find issues created by the bot. For example: q: epo:${context.repo.owner}/${context.repo.repo} is:issue is:open "${prUrl}" in:title in:body author:github-actions.

🤖 Prompt for AI Agent
Fix this bug. In .github/workflows/create-issue-for-unreferenced-pr.yml at lines 73-75:
The GitHub API search query in `existingIssuesResponse` is intended to find duplicate
issues created by the automation. However, it is missing an `author` filter to limit the
search to issues created by the `github-actions` bot. Consequently, the search will
match any open issue that contains the pull request URL, regardless of who created it.
If a user manually creates an issue and references the PR URL, the automation will
incorrectly determine an issue already exists and will skip creating its own necessary
tracking issue.

Did we get this right? 👍 / 👎 to inform future reviews.

Comment on lines +71 to +81
// Check if there's already an issue created by this automation for this PR
// Search for issues that mention this PR and were created by github-actions bot
const existingIssuesResponse = await github.rest.search.issuesAndPullRequests({
q: `repo:${context.repo.owner}/${context.repo.repo} is:issue is:open "${prUrl}" in:title in:body`,
});
if (existingIssuesResponse.data.total_count > 0) {
const existingIssue = existingIssuesResponse.data.items[0];
console.log(`An issue (#${existingIssue.number}) already exists for PR #${prNumber}, skipping creation.`);
return;
}

Choose a reason for hiding this comment

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

The comment mentions filtering for issues 'created by github-actions bot', but the search query doesn't actually include a creator filter. This could result in false positives by matching issues created by other users or bots that happen to mention the PR URL. Consider updating the search query to filter by creator: creator:github-actions or user:github-actions to ensure you're only detecting issues created by this automation.
Severity: MEDIUM

🤖 Prompt for AI Agent

Fix this code. In .github/workflows/create-issue-for-unreferenced-pr.yml#L71-L81: The
comment mentions filtering for issues 'created by github-actions bot', but the search
query doesn't actually include a creator filter. This could result in false positives by
matching issues created by other users or bots that happen to mention the PR URL.
Consider updating the search query to filter by creator: `creator:github-actions` or
`user:github-actions` to ensure you're only detecting issues created by this automation.

Did we get this right? 👍 / 👎 to inform future reviews.

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.

3 participants