Skip to content

Fix duplicate GitHub issue creation and implement file-based title format#47

Merged
BorDevTech merged 2 commits into
mainfrom
copilot/fix-46
Sep 22, 2025
Merged

Fix duplicate GitHub issue creation and implement file-based title format#47
BorDevTech merged 2 commits into
mainfrom
copilot/fix-46

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Sep 22, 2025

This PR addresses the duplicate issue creation problem where simultaneous workflow runs would create identical GitHub issues for the same lint violations. It also implements the requested file-based title format for better organization.

Problem

Issues #44 and #45 were identical duplicates created when multiple workflow runs executed simultaneously:

  • Both reported the same ESLint violation (HStack unused in StateSelector.tsx)
  • Both had identical titles and content
  • Created within 1 minute of each other due to race conditions

Solution

1. Enhanced Duplicate Prevention

Improved the checkExistingRuleIssue method with multiple search strategies:

// Before: Single search query
const searchQuery = `repo:${this.owner}/${this.repo}+is:issue+is:open+"Fix ${ruleId} violations"`;

// After: Multiple search strategies
const searchQueries = [
  `repo:${this.owner}/${this.repo}+is:issue+is:open+"Fix ${ruleId} violations"`,
  `repo:${this.owner}/${this.repo}+is:issue+is:open+"${ruleId}"+label:lint+label:automated`,
  `repo:${this.owner}/${this.repo}+is:issue+is:open+in:body+"Rule: ${ruleId}"`
];

2. Race Condition Protection

Added randomized delays and double-checking to prevent simultaneous issue creation:

// Random delay to stagger workflow executions
const delay = Math.floor(Math.random() * 3000) + 1000; // 1-4 seconds
await new Promise(resolve => setTimeout(resolve, delay));

// Double-check after delay
const finalCheck = await this.checkExistingFileIssue(fileName);
if (finalCheck) {
  console.log(`Race condition detected: ${fileName} - issue created by another process`);
  continue;
}

3. File-Based Title Format

Changed from rule-based to file-based issue organization as requested:

Before:

  • Title: 🔧 Fix @typescript-eslint/no-unused-vars violations (1 instances)
  • Grouped by ESLint rule

After:

  • Title: StateSelector.tsx (filename)
  • Body: # StateSelector.tsx with problems as ## 🔧 rule-name headers
  • Grouped by file for easier tracking

4. Improved Issue Body Structure

The new format provides better organization with file-focused content:

# StateSelector.tsx

**1 lint issue(s) found in this file across 1 rule(s).**

### 📁 File Details
- **File:** `app/components/StateSelector.tsx`
- **Issues:** 1
- **Rules:** @typescript-eslint/no-unused-vars

## 🔧 @typescript-eslint/no-unused-vars
**1 instance(s) of this rule violation.**

### 📍 Violations
- **Line 3:3** - 'HStack' is defined but never used.

5. Migration Support

Added automatic migration from old rule-based to new file-based format:

  • Detects existing rule-based issues
  • Closes them with migration comments
  • Creates new file-based issues to replace them

Additional Fixes

  • Fixed the actual lint issue by removing the unused HStack import from StateSelector.tsx
  • Added better error handling to continue processing if one group fails
  • Improved logging for better debugging of the duplicate prevention system

Verification

  • ✅ TypeScript compilation successful
  • ✅ ESLint passes with no errors (npm run lint)
  • ✅ Next.js build successful
  • ✅ Issue creator confirmed to use new filename format
  • ✅ Race condition protection working as expected

This change ensures that workflow runs will no longer create duplicate issues and provides the requested file-based organization for better lint issue tracking.

Fixes #46.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

@vercel
Copy link
Copy Markdown

vercel Bot commented Sep 22, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
clear-view Ready Ready Preview Comment Sep 22, 2025 4:04am

Co-authored-by: BorDevTech <73800053+BorDevTech@users.noreply.github.com>
Copilot AI changed the title [WIP] Duplicate created, workflow run at same time and creates duplicate Fix duplicate GitHub issue creation and implement file-based title format Sep 22, 2025
Copilot AI requested a review from BorDevTech September 22, 2025 04:05
@BorDevTech BorDevTech marked this pull request as ready for review September 22, 2025 04:07
Copilot AI review requested due to automatic review settings September 22, 2025 04:07
@BorDevTech BorDevTech merged commit f1671a1 into main Sep 22, 2025
8 checks passed
@BorDevTech BorDevTech deleted the copilot/fix-46 branch September 22, 2025 04:07
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 addresses duplicate GitHub issue creation by implementing enhanced duplicate prevention, race condition protection, and a new file-based title format. The changes prevent multiple workflow runs from creating identical issues for the same lint violations and improve issue organization by grouping violations by file rather than by rule.

Key changes:

  • Enhanced duplicate detection with multiple search strategies and race condition protection
  • Migration from rule-based to file-based issue organization format
  • Fixed the actual lint violation by removing unused HStack import

Reviewed Changes

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

File Description
scripts/lint-automation/github-issue-creator.ts Implements enhanced duplicate prevention, file-based issue format, and race condition protection
app/components/StateSelector.tsx Removes unused HStack import to fix the lint violation

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread scripts/lint-automation/github-issue-creator.ts
Comment thread scripts/lint-automation/github-issue-creator.ts
Comment thread scripts/lint-automation/github-issue-creator.ts
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.

Duplicate created, workflow run at same time and creates duplicate

3 participants