Fix duplicate draft issue creation in update-project#14323
Conversation
Add deduplication logic to check for existing draft issues by title before creating new ones. When updating fields on a draft issue, the code now reuses the existing item ID instead of creating a duplicate. Changes: - Added findExistingDraftByTitle helper function to query project items - Modified draft issue creation to check for existing drafts first - Only creates new draft if no matching title found - Added existingDraftItemResponse test helper - Updated all tests to include emptyItemsResponse for deduplication check - Added new test case for reusing existing draft issues Co-authored-by: mnkiefer <8320933+mnkiefer@users.noreply.github.com>
|
@copilot A good mental model is: Changing board stuff → use ProjectV2Item.id Changing content → use the content’s own ID |
Thanks for the clarification! The implementation already follows this model correctly:
This matches the pattern used for issues/PRs at line 865 where |
|
@copilot The issue is that for a series of safe outputs (see below for draft issue, issue, and pr), draft issue update just create a new draft issue instead of updating the existing one, while the others (issue, pr) get updated correctly: |
The deduplication wasn't working because __typename was being checked but not requested in the GraphQL query. This caused the check to always fail since __typename was undefined. Changes: - Added __typename to the GraphQL query for draft issue content - Now the __typename === "DraftIssue" check works correctly - Deduplication now properly identifies existing draft issues Co-authored-by: mnkiefer <8320933+mnkiefer@users.noreply.github.com>
Found the bug! The GraphQL query wasn't requesting Fixed in commit 38d5373 by adding |
|
@copilot recompile workflows |
There was a problem hiding this comment.
Pull request overview
This PR fixes update_project draft-issue behavior to avoid creating duplicate draft issues when the same draft_title is used repeatedly, by detecting and reusing an existing draft issue item in the target Projects v2 board.
Changes:
- Added a paginated GraphQL lookup to find an existing draft issue by exact title match before creating a new draft.
- Updated draft issue creation flow to reuse an existing project item ID when found, otherwise create a new draft.
- Expanded/updated tests to cover both “create new” and “reuse existing” draft issue paths (including the GraphQL
__typenamerequirement).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| actions/setup/js/update_project.cjs | Adds draft-issue deduplication by title via ProjectV2 item pagination and uses __typename to reliably detect DraftIssue content. |
| actions/setup/js/update_project.test.cjs | Adds test helper for existing draft items and updates/adds tests to validate deduplication behavior and new logging. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Workflows recompiled successfully. All 147 workflows compiled without errors. No lock file changes needed - the JavaScript fix doesn't affect the compiled workflow output. |
🔍 PR Triage ResultsCategory: bug | Risk: medium | Priority: 72/100 Scores Breakdown
📋 Recommended Action: fast_trackThis is a high-priority bug fix that should be merged immediately once CI passes. The duplicate draft issue creation affects project board reliability and data integrity. The PR has excellent quality with thorough root cause analysis and comprehensive test coverage. Next Step: Merge once CI stabilizes - this is critical for project board operations. Triaged by PR Triage Agent on 2026-02-07
|
Fix duplicate draft issue creation in update-project
Problem: When calling
update_projectwithcontent_type: "draft_issue"and field updates, the code always creates a new draft issue even if one with the same title already exists. This causes duplicate draft issues when the intent is to update an existing draft.Plan:
Changes Made:
findExistingDraftByTitlehelper function that queries all project items looking for DraftIssue content with matching title__typenameto GraphQL query (line 635) so the type check works correctlyexistingDraftItemResponsetest helper functionemptyItemsResponse()for deduplication checkRoot Cause:
The deduplication logic was checking for
item.content?.__typename === "DraftIssue"but the GraphQL query didn't request__typename, causing it to always be undefined. This made the check always fail, so existing drafts were never found.Test Results:
💡 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.