jlcodes99/cockpit-tools · warning
crontab_value_out_of_range
crontab_value_out_of_range
Error message
crontab_value_out_of_range
What it means
validateCrontabValue in WakeupTasksPage checks that a parsed crontab field value lies within [min, max] for its unit; out-of-range values throw Error('crontab_value_out_of_range'). Day-of-week 7 is tolerated only when normalizeDayOfWeek is true (it is normalized to 0 elsewhere).
Source
Thrown at src/pages/WakeupTasksPage.tsx:455
const normalizeCrontabDayOfWeek = (value: number) => (value === 7 ? 0 : value);
const parseCrontabNumber = (raw: string): number => {
const parsed = Number.parseInt(raw.trim(), 10);
if (Number.isNaN(parsed)) {
throw new Error('invalid_crontab_number');
}
return parsed;
};
const validateCrontabValue = (
value: number,
min: number,
max: number,
normalizeDayOfWeek: boolean,
) => {
if (normalizeDayOfWeek && value === 7) return;
if (value < min || value > max) {
throw new Error('crontab_value_out_of_range');
}
};
const insertCrontabRange = (
target: Set<number>,
start: number,
end: number,
step: number,
normalizeDayOfWeek: boolean,
) => {
for (let value = start; value <= end; value += step) {
target.add(normalizeDayOfWeek ? normalizeCrontabDayOfWeek(value) : value);
}
};
const parseCrontabSegment = (
segment: string,
min: number,View on GitHub (pinned to 1ed8b77992)
Solutions
- Fix the out-of-range value: minutes 0-59, hours 0-23, day-of-month 1-31, months 1-12, day-of-week 0-7 (7 normalized to Sunday where supported).
- Use the page's field pickers to generate in-range values instead of editing the cron string directly.
- Replace day-of-week 7 with 0 if the validation path doesn't normalize it.
- Validate the expression before save and show the offending field to the user.
Example fix
// before '0 0 * * 8' // throws crontab_value_out_of_range // after '0 0 * * 0' // Sunday as 0
Defensive patterns
Strategy: validation
Validate before calling
const CRON_RANGES = { minute: [0,59], hour: [0,23], dom: [1,31], month: [1,12], dow: [0,7] } as const;
const inRange = (v: number, [min, max]: readonly [number, number]) => v >= min && v <= max; Try / catch
try {
saveCron(expression);
} catch (e) {
if (e.message === 'crontab_value_out_of_range') {
showFieldError('cron', '字段值超出允许范围');
return;
}
throw e;
} Prevention
- Clamp or reject values against per-field ranges before building the expression.
- Replace day-of-week 7 with 0 when the parser's normalizeDayOfWeek is off.
- Use bounded pickers so users cannot enter values outside the valid range.
When it happens
Trigger: A crontab field contains a numeric value outside the unit's valid range — e.g. minute 60+, hour 24+, day-of-month 32+, month 13+, day-of-week 8+ — or day-of-week 7 with normalizeDayOfWeek false.
Common situations: User types 25 for hour or 8 for day-of-week in the free-text cron input; expressions copied from schedulers with looser rules (7 = Sunday) hit strict validation; off-by-one mistakes when hand-assembling ranges like '0-60/5'.
Related errors
- invalid_crontab_number
- invalidJsonMessage
- messages.invalidJson
- errorCode (parseJsonOrThrow caller-supplied)
- [WakeupGateway] 官方 LS LanguageServerStarted 解析失败: {}
AI-assisted analysis of jlcodes99/cockpit-tools@1ed8b77992 (2026-09-05).
Data as JSON: /api/errors/f74edcb10cb8d836.
Report an issue: GitHub.