actualbudget/actual · error

Weekly limit requires a start date (YYYY-MM-DD)

Error message

Weekly limit requires a start date (YYYY-MM-DD)

What it means

A weekly limit (`up to ... weekly`) must include an explicit start date in YYYY-MM-DD format so the engine knows where week boundaries fall. `checkLimit` throws when `limitDef.period === 'weekly'` but `limitDef.start` is missing.

Source

Thrown at packages/loot-core/src/server/budget/category-template-context.ts:601

          continue; // may not have a limit defined in the template
        }
      }

      if (this.limitCheck) {
        throw new Error('Only one `up to` allowed per category');
      }

      if (limitDef.period === 'daily') {
        const numDays = monthUtils.differenceInCalendarDays(
          monthUtils.addMonths(this.month, 1),
          this.month,
        );
        this.limitAmount +=
          amountToInteger(limitDef.amount, this.currency.decimalPlaces) *
          numDays;
      } else if (limitDef.period === 'weekly') {
        if (!limitDef.start) {
          throw new Error('Weekly limit requires a start date (YYYY-MM-DD)');
        }
        const nextMonth = monthUtils.nextMonth(this.month);
        let week = limitDef.start;
        const baseLimit = amountToInteger(
          limitDef.amount,
          this.currency.decimalPlaces,
        );
        while (week < nextMonth) {
          if (week >= this.month) {
            this.limitAmount += baseLimit;
          }
          week = monthUtils.addWeeks(week, 1);
        }
      } else if (limitDef.period === 'monthly') {
        this.limitAmount = amountToInteger(
          limitDef.amount,
          this.currency.decimalPlaces,
        );

View on GitHub (pinned to d4334cb6e6)

Solutions

  1. Add the `starting YYYY-MM-DD` clause to the weekly limit, e.g. `#template up to 100 weekly starting 2024-01-01`
  2. Or switch the limit to a period that does not require a start date (monthly, daily)

Example fix

// before
#template up to 100 weekly
// after
#template up to 100 weekly starting 2024-01-01
Defensive patterns

Strategy: validation

Validate before calling

if (/weekly/.test(line) && !/starting \d{4}-\d{2}-\d{2}/.test(line)) throw new Error('weekly limit needs: starting YYYY-MM-DD');

Type guard

function hasWeeklyStart(limitDef) {
  return limitDef.period !== 'weekly' || typeof limitDef.start === 'string' && /^\d{4}-\d{2}-\d{2}$/.test(limitDef.start);
}

Try / catch

try {
  await init();
} catch (e) {
  if (e.message.includes('Weekly limit requires a start date')) {
    // append `starting YYYY-MM-DD` to the weekly limit line
  } else throw e;
}

Prevention

When it happens

Trigger: A template like `#template up to 100 weekly` (no `starting <date>` clause) is processed by `checkLimit` during category context construction — the weekly period requires `start` to compute aligned week windows across the budget month.

Common situations: Writing a weekly limit template without the required `starting YYYY-MM-DD` clause; hand-editing templates after reading older docs; converting a monthly limit template to weekly by only changing the period keyword.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of actualbudget/actual@d4334cb6e6 (2026-08-29). Data as JSON: /api/errors/31ecd28b42d60882. Report an issue: GitHub.