molecule-core/platform
molecule-ai[bot] b83ddc7dff
fix(scheduler): prevent NULL next_run_at from permanently dropping schedules (#722)
Three bugs caused enabled schedules to silently disappear from the fire query
(which requires next_run_at IS NOT NULL AND next_run_at <= now()):

Bug 1 - fireSchedule() and recordSkipped(): when ComputeNextRun returned an
error, nextRunPtr stayed nil and UPDATE SET next_run_at = $2 wrote NULL.
Fix: change to COALESCE($2, next_run_at) so the existing DB value is preserved
when $2 is NULL, and log the error explicitly.

Bug 2 - org importer (handlers/org.go): nextRun, _ := ComputeNextRun(...)
silently discarded the error. A bad cron expression would pass time.Time{}
(zero value) to the INSERT. Fix: surface the error, log it, and skip the
schedule INSERT via continue.

Bug 3 - no startup repair: schedules already NULL'd by the pre-fix binary
would never recover. Fix: Start() now calls repairNullNextRunAt() once on
boot, recomputing next_run_at for every enabled schedule with a NULL value.

Tests: TestFireSchedule_ComputeNextRunError, TestRecordSkipped_ComputeNextRunError,
TestRepairNullNextRunAt_RepairsRows, TestRepairNullNextRunAt_DBError_NoPanic,
TestOrgImport_ScheduleComputeError (all pass).

Fixes #722

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-17 13:34:28 +00:00
..
cmd/server feat(platform): wire github-app-auth plugin for per-installation tokens 2026-04-16 12:52:20 -07:00
docs/adr fix(wsauth): restore ValidateAnyToken removed-workspace JOIN (#682 defense-in-depth), restore ADR-001 blast-radius docs 2026-04-17 12:25:44 +00:00
internal fix(scheduler): prevent NULL next_run_at from permanently dropping schedules (#722) 2026-04-17 13:34:28 +00:00
migrations fix(security): revert #684 schema migration, restore /admin/schedules/health, add ADR-001 2026-04-17 12:01:12 +00:00
pkg/provisionhook fix(github): refresh installation token when TTL < 10 min (#547) (#567) 2026-04-17 00:47:03 +00:00
Dockerfile fix: address all code review findings + remove exposed secrets 2026-04-16 05:05:49 -07:00
Dockerfile.tenant fix: address all code review findings + remove exposed secrets 2026-04-16 05:05:49 -07:00
entrypoint-tenant.sh feat(platform): auto-detect SaaS tenant → control plane provisioner 2026-04-16 11:50:52 -07:00
go.mod feat(platform): wire github-app-auth plugin for per-installation tokens 2026-04-16 12:52:20 -07:00
go.sum feat(platform): wire github-app-auth plugin for per-installation tokens 2026-04-16 12:52:20 -07:00