Skip to content

Latest commit

 

History

History
51 lines (40 loc) · 2.45 KB

File metadata and controls

51 lines (40 loc) · 2.45 KB

Milestone Creation Fix - Duplicate Title Resolution

Problem Fixed

The milestone creation was failing with validation error: "Validation Failed: {"resource":"Milestone","code":"already_exists","field":"title"}" when multiple AI development plans were created on the same day.

Root Cause

The milestone title was using a static format based only on the date:

title: `AI Development Plan - ${currentDate.toISOString().split('T')[0]}`

This generated titles like:

  • AI Development Plan - 2025-01-28
  • AI Development Plan - 2025-01-28 (duplicate - causes error)

Solution Implemented

Modified the createProjectMilestone() function in /workspaces/uwularpy/src/trigger/plan-implementation.ts to use a unique timestamp-based title with random suffix:

// Generate unique milestone title with timestamp and random component to avoid duplicates
const timestamp = currentDate.toISOString().replace(/:/g, '-').replace(/\./g, '-');
const randomSuffix = Math.random().toString(36).substr(2, 4); // 4 random characters
const uniqueTitle = `AI Development Plan - ${timestamp}-${randomSuffix}`;

This now generates unique titles like:

  • AI Development Plan - 2025-06-03T15-30-45-123Z-a1b2
  • AI Development Plan - 2025-06-03T15-30-45-456Z-c3d4

Benefits

  1. Eliminates Duplicate Title Errors: Each milestone has a unique timestamp + random suffix
  2. Maintains Readability: Still includes recognizable "AI Development Plan" prefix
  3. Preserves Chronological Order: Timestamp allows sorting by creation time
  4. Handles Rapid Creation: Random suffix ensures uniqueness even for simultaneous requests
  5. No Breaking Changes: Existing functionality remains intact

Technical Details

  • Uses ISO string timestamp with colons and periods replaced by hyphens for GitHub compatibility
  • Adds 4-character random suffix using base36 encoding for additional uniqueness
  • Maintains millisecond precision combined with randomness for guaranteed uniqueness
  • Automatically handles timezone normalization through ISO format

Testing

Created test script test-unique-milestone-titles.js to verify unique title generation for multiple rapid creations.

Files Modified

  • /workspaces/uwularpy/src/trigger/plan-implementation.ts - Fixed milestone title generation
  • Added documentation comment explaining the uniqueness requirement

Status

FIXED - Multiple AI development plans can now be created on the same day without validation conflicts.