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.
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-28AI Development Plan - 2025-01-28(duplicate - causes error)
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-a1b2AI Development Plan - 2025-06-03T15-30-45-456Z-c3d4
- Eliminates Duplicate Title Errors: Each milestone has a unique timestamp + random suffix
- Maintains Readability: Still includes recognizable "AI Development Plan" prefix
- Preserves Chronological Order: Timestamp allows sorting by creation time
- Handles Rapid Creation: Random suffix ensures uniqueness even for simultaneous requests
- No Breaking Changes: Existing functionality remains intact
- 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
Created test script test-unique-milestone-titles.js to verify unique title generation for multiple rapid creations.
/workspaces/uwularpy/src/trigger/plan-implementation.ts- Fixed milestone title generation- Added documentation comment explaining the uniqueness requirement
✅ FIXED - Multiple AI development plans can now be created on the same day without validation conflicts.