sickn33/agentic-awesome-skills · error · CronError
Expected 5 fields (got ${parts.length}). Format: minute hour
Error message
Expected 5 fields (got ${parts.length}). Format: minute hour day-of-month month day-of-week What it means
parseCron splits the expression on whitespace and requires exactly 5 fields: minute hour day-of-month month day-of-week. Any other count is rejected immediately. This engine does not support a 6th seconds field, a year field, or @shorthands like @daily.
Source
Thrown at skills/cron-doctor/scripts/cron-engine.js:171
values.add(v);
}
function addRange(values, lo, hi, fieldDef) {
if (lo > hi) [lo, hi] = [hi, lo];
if (lo < fieldDef.min || hi > fieldDef.max) {
throw new CronError(`Range ${lo}-${hi} out of bounds for ${fieldDef.name} (${fieldDef.min}-${fieldDef.max})`, -1);
}
for (let v = lo; v <= hi; v++) {
if (fieldDef.key === 'dow' && v === 7) { values.add(0); continue; }
values.add(v);
}
}
// ---- Full expression parser ----
function parseCron(expr) {
const parts = String(expr).trim().split(/\s+/);
if (parts.length !== 5) {
throw new CronError(`Expected 5 fields (got ${parts.length}). Format: minute hour day-of-month month day-of-week`, -1);
}
const parsed = {};
for (let i = 0; i < 5; i++) {
parsed[FIELDS[i].key] = parseField(parts[i], FIELDS[i], i);
}
parsed.domRestricted = !/^\s*\*\s*$/.test(parts[2]);
parsed.dowRestricted = !/^\s*\*\s*$/.test(parts[4]);
parsed.parts = parts;
return parsed;
}
// ---- Human-readable description ----
function describe(expr) {
let parsed;
try { parsed = parseCron(expr); } catch (e) { return { text: e.message, error: true }; }
return { text: describeParsed(parsed), error: false, parsed };
}
View on GitHub (pinned to 58d857988f)
Solutions
- Reduce to exactly 5 fields: drop a leading seconds field or trailing year
- Replace @shorthands manually: @daily -> '0 0 * * *', @hourly -> '0 * * * *'
- Count whitespace-separated tokens; the message reports how many were found
Example fix
// before '0 30 9 * * *' // 6 fields (seconds first) // after '30 9 * * *' // 5 fields
Defensive patterns
Strategy: validation
Validate before calling
const n = String(expr).trim().split(/\s+/).filter(Boolean).length;
if (n !== 5) throw new Error(`Expected 5 fields, got ${n}`);
const parsed = parseCron(expr); Try / catch
try { parseCron(expr); } catch (e) { if (e instanceof CronError && /Expected 5 fields/.test(e.message)) promptForFiveFieldCron(expr); else throw e; } Prevention
- Normalize @daily/@hourly to 5-field equivalents before parsing
- Strip a leading seconds field when importing Quartz/Spring cron
- Validate user-entered schedules client-side before saving
When it happens
Trigger: Passing a 6-field expression with seconds ('0 0 0 * * *'), a 7-field Quartz-style cron, '@daily'/'@hourly'/'@reboot' strings, or an expression with a missing field ('0 0 * *').
Common situations: Copying a Quartz (7 fields) or Spring (6 fields) cron into a standard 5-field tool; assuming @ macros exist; accidentally deleting a field while editing.
Related errors
- Invalid range "${t}" in ${fieldDef.name}
- Value ${v} out of range for ${fieldDef.name} (${fieldDef.min
- Range ${lo}-${hi} out of bounds for ${fieldDef.name} (${fiel
- Invalid age
- Age cannot be negative
AI-assisted analysis of sickn33/agentic-awesome-skills@58d857988f (2026-08-26).
Data as JSON: /api/errors/1b6f4a060e7b06dd.
Report an issue: GitHub.