{"record":{"id":"85c9b97d4c886d18","repo":"mastra-ai/mastra","slug":"platform-linear-event-polling-interval-must-be-a-p","errorCode":null,"errorMessage":"Platform Linear event polling interval must be a positive number.","messagePattern":"Platform Linear event polling interval must be a positive number\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"mastracode/factory/src/integrations/platform/linear/event-worker.ts","lineNumber":157,"sourceCode":"  #hasLease = false;\n  #startedAt = 0;\n  #lastReconcileAt = 0;\n  #settings: PlatformLinearEventWorkerSettings = { version: 1, workspaces: {} };\n\n  constructor(config: PlatformLinearEventWorkerConfig) {\n    super();\n    this.#client = config.client;\n    this.#linear = config.linear;\n    this.#storage = config.storage;\n    this.#projects = config.projects;\n    this.#workItems = config.workItems;\n    this.#ingestFactoryIssue = config.ingestFactoryIssue;\n    this.#reconcileFactoryState = config.reconcileFactoryState;\n    this.#pollEventsEnabled = config.pollEventsEnabled ?? true;\n    this.#intervalMs = config.intervalMs ?? DEFAULT_POLL_INTERVAL_MS;\n    this.#reconcileIntervalMs = config.reconcileIntervalMs ?? DEFAULT_RECONCILE_INTERVAL_MS;\n    if (!Number.isFinite(this.#intervalMs) || this.#intervalMs <= 0) {\n      throw new Error('Platform Linear event polling interval must be a positive number.');\n    }\n    if (!Number.isFinite(this.#reconcileIntervalMs) || this.#reconcileIntervalMs <= 0) {\n      throw new Error('Platform Linear reconcile interval must be a positive number.');\n    }\n    this.#leaseTtlMs = Math.max(MIN_LEASE_TTL_MS, this.#intervalMs * 3);\n    this.#now = config.now ?? Date.now;\n  }\n\n  async init(deps: WorkerDeps): Promise<void> {\n    await super.init(deps);\n    this.#leaseProvider = getLeaseProvider(deps.pubsub);\n  }\n\n  async start(): Promise<void> {\n    if (this.#running) return;\n    if (!this.deps) throw new Error('PlatformLinearEventWorker: call init() before start()');\n\n    this.#startedAt = this.#now() - 1;","sourceCodeStart":139,"sourceCodeEnd":175,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/mastracode/factory/src/integrations/platform/linear/event-worker.ts#L139-L175","documentation":"The Platform Linear event worker constructor validates that the event polling interval (`config.intervalMs`) is a finite number greater than 0 before starting. This check runs after applying the default (`DEFAULT_POLL_INTERVAL_MS`), so it only fires when an explicit interval was supplied but is invalid (0, negative, NaN, or Infinity). It is thrown synchronously at construction time so a misconfigured worker fails fast instead of silently never polling.","triggerScenarios":"Constructing the Linear event worker with `intervalMs` explicitly set to 0, a negative number, NaN, or Infinity (e.g. `intervalMs: Number.parseInt(process.env.LINEAR_POLL_MS ?? '')` where the env value parses to NaN).","commonSituations":"Env vars like `LINEAR_POLL_MS=0` or `LINEAR_POLL_MS=abc` parsed with Number() and passed through unvalidated; a config generator emitting 0 for 'disabled'; floating-point computed values like `seconds * 1000` where seconds was NaN.","solutions":["Set `intervalMs` to a finite positive integer in milliseconds (e.g. 30000).","If you want polling disabled, use `pollEventsEnabled: false` instead of intervalMs: 0.","Validate the env/config value before passing it: `const n = Number(raw); if (Number.isSafeInteger(n) && n > 0) config.intervalMs = n;`","Omit `intervalMs` entirely to use DEFAULT_POLL_INTERVAL_MS."],"exampleFix":"// before\nnew LinearEventWorker({ intervalMs: Number(process.env.LINEAR_POLL_MS), ... });\n// after\nconst pollMs = Number(process.env.LINEAR_POLL_MS);\nnew LinearEventWorker({ intervalMs: Number.isSafeInteger(pollMs) && pollMs > 0 ? pollMs : undefined, ... });","handlingStrategy":"validation","validationCode":"function isValidInterval(v: unknown): v is number {\n  return typeof v === 'number' && Number.isFinite(v) && v > 0;\n}\nif (config.intervalMs !== undefined && !isValidInterval(config.intervalMs)) {\n  throw new Error('intervalMs must be a finite positive number');\n}","typeGuard":"function isPositiveFiniteNumber(v: unknown): v is number {\n  return typeof v === 'number' && Number.isFinite(v) && v > 0;\n}","tryCatchPattern":null,"preventionTips":["Never pass Number(env) directly; validate with Number.isSafeInteger before assigning.","Use pollEventsEnabled: false to disable polling instead of interval 0.","Centralize env parsing in one typed helper that returns undefined for invalid input."],"tags":["configuration","validation","linear","polling"],"backgroundTag":"invalid-interval-config","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T08:17:16.595Z"}