mastra-ai/mastra · error

Platform GitHub issue reconcile interval must be a positive

Error message

Platform GitHub issue reconcile interval must be a positive number.

What it means

Thrown from the PlatformGithubEventWorker constructor (event-worker.ts:156) when config.issueReconcileIntervalMs (or the legacy reconcileIntervalMs fallback) is provided but is not a finite number greater than 0. This interval controls how often issues are reconciled with GitHub; the constructor fails fast because a non-positive value would produce a busy loop.

Source

Thrown at mastracode/factory/src/integrations/platform/github/event-worker.ts:156

    this.#controller = config.controller;
    this.#github = config.github;
    this.#storage = config.storage;
    this.#ingestFactoryEvent = config.ingestFactoryEvent;
    this.#reconcileFactoryState = config.reconcileFactoryState;
    this.#reconcileIssuesFactoryState = config.reconcileIssuesFactoryState;
    this.#pollEventsEnabled = config.pollEventsEnabled ?? true;
    const legacyReconcileIntervalMs = config.reconcileIntervalMs ?? DEFAULT_RECONCILE_INTERVAL_MS;
    this.#pullRequestReconcileIntervalMs = config.pullRequestReconcileIntervalMs ?? legacyReconcileIntervalMs;
    this.#issueReconcileIntervalMs = config.issueReconcileIntervalMs ?? legacyReconcileIntervalMs;
    this.#intervalMs = config.intervalMs ?? DEFAULT_POLL_INTERVAL_MS;
    if (!Number.isFinite(this.#intervalMs) || this.#intervalMs <= 0) {
      throw new Error('Platform GitHub event polling interval must be a positive number.');
    }
    if (!Number.isFinite(this.#pullRequestReconcileIntervalMs) || this.#pullRequestReconcileIntervalMs <= 0) {
      throw new Error('Platform GitHub pull request reconcile interval must be a positive number.');
    }
    if (!Number.isFinite(this.#issueReconcileIntervalMs) || this.#issueReconcileIntervalMs <= 0) {
      throw new Error('Platform GitHub issue reconcile interval must be a positive number.');
    }
    this.#leaseTtlMs = Math.max(
      MIN_LEASE_TTL_MS,
      Math.min(this.#intervalMs, this.#pullRequestReconcileIntervalMs, this.#issueReconcileIntervalMs) * 3,
    );
    this.#now = config.now ?? Date.now;
    this.#dispatch = config.dispatch ?? dispatchGithubWebhook;
    this.#sourceControl = config.sourceControl;
  }

  async init(deps: WorkerDeps): Promise<void> {
    await super.init(deps);
    this.#leaseProvider = getLeaseProvider(deps.pubsub);
  }

  async start(): Promise<void> {
    if (this.#running) return;
    if (!this.deps) throw new Error('PlatformGithubEventWorker: call init() before start()');

View on GitHub (pinned to 75dd419e61)

Solutions

  1. Set issueReconcileIntervalMs to a positive finite number of milliseconds.
  2. Omit the field so it inherits the sane default via reconcileIntervalMs/DEFAULT_RECONCILE_INTERVAL_MS.
  3. Sanitize env- or config-derived numbers: only pass them when Number.isFinite(v) && v > 0.
  4. Set a correct legacy reconcileIntervalMs if both PR and issue intervals should share one value.

Example fix

// before
new PlatformGithubEventWorker({ issueReconcileIntervalMs: Number(config.issues?.reconcileMs ?? 0) });

// after
const v = Number(config.issues?.reconcileMs);
new PlatformGithubEventWorker({
  ...(Number.isFinite(v) && v > 0 ? { issueReconcileIntervalMs: v } : {}),
});
Defensive patterns

Strategy: validation

Validate before calling

const raw = config.issueReconcileIntervalMs ?? config.reconcileIntervalMs;
if (raw !== undefined && !(Number.isFinite(Number(raw)) && Number(raw) > 0)) {
  throw new TypeError(`issueReconcileIntervalMs must be positive, got ${String(raw)}`);
}

Type guard

function isValidInterval(v: unknown): v is number {
  return typeof v === 'number' && Number.isFinite(v) && v > 0;
}

Try / catch

try {
  const worker = new PlatformGithubEventWorker(config);
} catch (err) {
  if (err instanceof Error && err.message.includes('issue reconcile interval')) {
    logger.error('Invalid issueReconcileIntervalMs', { value: config.issueReconcileIntervalMs });
  }
  throw err;
}

Prevention

When it happens

Trigger: new PlatformGithubEventWorker({ ..., issueReconcileIntervalMs: 0 }) or a negative/NaN/Infinity value; the same bad value reaching it via legacy config.reconcileIntervalMs when issueReconcileIntervalMs is unset.

Common situations: Issue-specific reconcile timing added recently and seeded from an unset env var (Number('') === 0 or NaN); copy-paste config where only the PR interval was filled in; unvalidated dashboard/admin-supplied tuning values.

Understand the failure class

Background: "Invalid configuration value" and "Unsupported/Unknown setting value" errors: why libraries reject your config strings, numbers, and types — this error's family across 30 libraries.

Related errors


AI-assisted analysis of mastra-ai/mastra@75dd419e61 (2026-08-30). Data as JSON: /api/errors/3c995a65ef60e57b. Report an issue: GitHub.