fix: improve CRON schedule validation and display (#16360)
Fixes multiple issues with CRON schedule input validation and execution time display. ### Issues Fixed 1. **UTC label placement** - Added "UTC" suffix to specific times (e.g., "at 09:30 UTC") but not to interval descriptions (e.g., "every hour") 2. **Upcoming execution time calculation** - Fixed incorrect execution times for malformed CRON expressions by implementing auto-correction ### Changes - Created `normalizeCronExpression` utility to standardize cron expressions before parsing - Updated `formatTime` to support optional UTC suffix - Enhanced `getHoursDescription` to append UTC to specific times - Added comprehensive test coverage (102 tests passing) ### Before - `"1 /3 * * *"` showed daily executions at same time (incorrect) - `"9 * * *"` showed same time repeated 3 times (incorrect) - No UTC labels on schedule descriptions (confusing) ### After - All malformed expressions auto-corrected and show correct execution times - UTC labels clearly indicate timezone for specific times - User-friendly error messages for truly invalid patterns Closes #15870
This commit is contained in:
+10
-3
@@ -220,12 +220,19 @@ function assertCronTriggerSettingsAreValid(settings: any) {
|
||||
);
|
||||
}
|
||||
|
||||
if (settings.schedule.minute <= 0) {
|
||||
if (settings.schedule.minute <= 0 || settings.schedule.minute > 60) {
|
||||
const errorMessage =
|
||||
settings.schedule.minute <= 0
|
||||
? msg`Invalid minute value. Should be integer greater than 1`
|
||||
: msg`Minute value cannot exceed 60. For intervals greater than 60 minutes, use the "Hours" trigger type or a custom cron expression`;
|
||||
|
||||
throw new WorkflowTriggerException(
|
||||
'Invalid minute value. Should be integer greater than 1',
|
||||
settings.schedule.minute <= 0
|
||||
? 'Invalid minute value. Should be integer greater than 1'
|
||||
: 'Invalid minute value. Cannot exceed 60. For intervals greater than 60 minutes, use the "Hours" trigger type or a custom cron expression',
|
||||
WorkflowTriggerExceptionCode.INVALID_WORKFLOW_TRIGGER,
|
||||
{
|
||||
userFriendlyMessage: msg`Invalid minute value. Should be integer greater than 1`,
|
||||
userFriendlyMessage: errorMessage,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user