Repository navigation
fix(platform): avoid duplicate OneDrive sync schedule on re-provision - #2509
Merged
Merged
Conversation
The sync engine re-provisions its `wfSchedules` trigger on every sync-config upsert. The guard was create-if-absent keyed on the exact cron string, so once an operator retuned the interval (e.g. to */2 via the trigger editor) the builtin's */15 no longer matched any row and a second, concurrently-firing schedule was inserted. Key provisioning on the automation instead of the cron: the sync engine owns a single, retunable schedule, so if any org-level schedule row for the slug already exists (active or paused, any cron) keep it and declare nothing new — `activate: true` still revives a paused one. Completeness now means "the automation has an active schedule", not "the declared cron has a row".
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The OneDrive/SharePoint sync engine re-provisions its
wfSchedulestrigger on every sync-config upsert (each time a folder is added to sync). The provisioning guard was create-if-absent keyed on the exact cron string — the identity it matched on was(org, workflowSlug, cronExpression, projectId === undefined).That means once an operator retunes the sync interval (e.g. to
*/2 * * * *via the trigger editor), the builtin's declared*/15 * * * *no longer matches any existing row, so the next re-provision inserts a second schedule. Both rows stayisActive: true, so the automation ends up firing on two different intervals at once. ThewfSchedulestable has no unique constraint to catch it, and nothing reconciled the divergent row.Fix
Key provisioning on the automation, not on the cron. The sync engine owns a single, retunable schedule, so:
activate: truepath still revives a paused one.The change is contained to
onedrive/ensure_sync_workflow_provision.ts; the sharedprovisionDeclaredWorkflowTriggersImpl(used by two other provisioning paths that may legitimately declare multiple distinct crons) is untouched.Behaviour
Note:
activate: trueis preserved, so adding a sync folder re-activates a paused schedule (existing behaviour, consistent with "ensure the automation has a live schedule").Tests
*/2→ assertsschedulesCreated: 0and a single*/2row remains.*/2→ asserts it is revived (schedulesReactivated: 1), not duplicated.@tale/platformtypecheck +bun run lintclean; all 37 OneDrive tests pass.