sickn33/agentic-awesome-skills · error · CronError

Value ${v} out of range for ${fieldDef.name} (${fieldDef.min

Error message

Value ${v} out of range for ${fieldDef.name} (${fieldDef.min}-${fieldDef.max})

What it means

addOne validates a single resolved numeric value against the field's min/max (minute 0-59, hour 0-23, dom 1-31, month 1-12, dow 0-6) and throws when it falls outside. Reached from parseItem for bare numbers and step bases. Special case: dow 7 is accepted and mapped to 0 (Sunday).

Source

Thrown at skills/cron-doctor/scripts/cron-engine.js:151

  }

  if (t.includes('-')) {
    const parts = t.split('-');
    if (parts.length !== 2) throw new CronError(`Invalid range "${t}" in ${fieldDef.name}`, fieldIndex);
    const a = parseSingleNum(parts[0].trim(), fieldDef, fieldIndex);
    const b = parseSingleNum(parts[1].trim(), fieldDef, fieldIndex);
    addRange(values, a, b, fieldDef);
    return;
  }

  const v = parseSingleNum(t, fieldDef, fieldIndex);
  addOne(values, v, fieldDef, fieldIndex);
}

function addOne(values, v, fieldDef, fieldIndex) {
  if (fieldDef.key === 'dow' && v === 7) { values.add(0); return; }
  if (v < fieldDef.min || v > fieldDef.max) {
    throw new CronError(`Value ${v} out of range for ${fieldDef.name} (${fieldDef.min}-${fieldDef.max})`, fieldIndex);
  }
  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+/);

View on GitHub (pinned to 58d857988f)

Solutions

  1. Clamp the value to the bounds shown in the message, e.g. hour 24 -> 0, minute 60 -> 0
  2. Use 0-6 for day-of-week (7 is accepted as Sunday)
  3. Remember day-of-month and month start at 1

Example fix

// before
'0 24 * * *'  // hour 24 invalid

// after
'0 0 * * *'   // midnight
Defensive patterns

Strategy: validation

Validate before calling

const LIMITS = { minute:[0,59], hour:[0,23], dom:[1,31], month:[1,12], dow:[0,7] };
const fields = String(expr).trim().split(/\s+/);
const valid = fields.length === 5 && fields.every((f, i) =>
  f.split(',').every(t => {
    const nums = t.split(/[-/]/).filter(s => /^\d+$/.test(s));
    return t === '*' || nums.length === 0 || nums.every(n => {
      const v = Number(n); return v >= LIMITS[i][0] && v <= LIMITS[i][1];
    });
  }));
if (!valid) throw new Error('Field value out of range');

Try / catch

try { parseCron(expr); } catch (e) { if (e instanceof CronError && /out of range/.test(e.message)) reportField(e.fieldIndex); else throw e; }

Prevention

When it happens

Trigger: Values like minute 60, hour 24, month 0 or 13, dom 0 or 32, dow 8; also step expressions whose base is out of range, e.g. '70/5' in the minute field.

Common situations: Using hour 24 for midnight; assuming 0-indexed months (JS Date getMonth() habits); off-by-one on day-of-week; porting expressions from schedulers with different bounds.

Related errors


AI-assisted analysis of sickn33/agentic-awesome-skills@58d857988f (2026-08-26). Data as JSON: /api/errors/ca61ee900fe35778. Report an issue: GitHub.