scm_pr_merged never fires for a pull request merged while a sync is running
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 64/100
Direzione di ricerca
Start in internal/scm/sync.go: read shouldEmitPRMergeEvent, shouldRunSmartCommits, syncRepository (where last_synced_at is written) and upsertPullRequestSCMLink. Trace the order of listing pull requests versus writing the checkpoint, then reproduce with a sync that starts before a merge and finishes after it. Done means a newly observed open-to-merged transition emits scm_pr_merged exactly once and smart commits run, while a newly connected repository does not replay history. Check the existing internal/scm tests before changing the check.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
A pull request that merges while a repository sync is in progress never fires the scm_pr_merged action trigger. The link is updated to merged, but no action event is recorded, so automations on "SCM: pull request merged" do not run for that pull request and never will.
Seen on v0.9.4 (2ebdd711) with a GitHub connection. The relevant code is the same on main.
What happened
Times are UTC, from the server log and the database:
- ~10:15:56 — a sync of the repository starts and lists the pull request while it is still open.
- 10:16:13 — the pull request is merged on GitHub.
- ~10:19 — that sync finishes and writes
last_synced_at. - 10:20:54 — the next sync sees the pull request as merged and sets
item_scm_links.statetomerged.
Afterwards the link row is merged, action_event_batches has no scm_pr_merged row for it, and the action has no entry in action_execution_logs. An scm_pr_linked action on the same item and pull request had run normally earlier.
Steps 1 and 3 are inferred from log timestamps; the sync was slow because the connection was being rate limited on the tag-listing step, which widened the window from seconds to minutes.
Cause
shouldEmitPRMergeEvent (via shouldRunSmartCommits) in internal/scm/sync.go only allows the event when the merge is newer than the checkpoint:
if !lastSyncedAt.IsZero() {
return pr.MergedAt.After(lastSyncedAt)
}
syncRepository writes the checkpoint at the end of a sync, after pull requests, commits, branches, tags and releases have all been processed:
UPDATE workspace_repositories SET last_synced_at = CURRENT_TIMESTAMP, ...
So the checkpoint is later than the moment the pull requests were listed. A merge that lands between the listing and the end of the sync has MergedAt < last_synced_at when the next sync observes it, emitMerged is false, and upsertPullRequestSCMLink moves the row to merged without emitting. Because the stored state is now merged, becameMerged is false on every later sync and the event is lost for good.
Smart commits for the pull request are skipped by the same check.
Possible fixes
- Record the time the sync started (before listing pull requests) and store that as
last_synced_at, so the checkpoint never passes a change the sync did not see. - Or, when a link already exists and its state changes from open to merged, emit regardless of
MergedAt. The stored previous state already shows the merge is new; the time check is only needed when the link is first created, to avoid replaying history on a newly connected repository.
Workaround
Move the affected item by hand. There is no way to re-fire the trigger once the link is merged.
- Lingua principale
- Go
- Stelle
- 421
- Fork
- 50
- Merge medio
- 17h 34m
- PR unite (30g)
- 80
Preparare l'ambiente
- Include un Dockerfile o un file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di Windshiftapp/core
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
Windshiftapp/core#542 ·
I maintainer di solito rispondono entro 1 giorno
-
Time Tracking FilteringAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 64/100
Windshiftapp/core#334 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
Windshiftapp/core#259 · 1 commento · 1 reazione ·
I maintainer di solito rispondono entro 1 giorno
-
[Bug][AI chat] Select menu dont appear when on index pageForse già presa @valentimarco l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 20/100
Windshiftapp/core#541 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 45/100
Windshiftapp/core#538 · 1 reazione ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di Windshiftapp/core
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
karmada-io/karmada#8101 ·
I maintainer di solito rispondono entro 1 giorno
-
product:platform
Difficoltà 2/5 1-3 ore Idoneità per principianti 77/100
Infisical/infisical#9746 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
CrossEntropyFilter raises on zero probabilities and single-class resultsForse già presa @NopeCharon l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100
txn2/mcp-data-platform#2728 ·
I maintainer di solito rispondono entro 1 giorno
-
effort:s impact:low raised-by:worker risk:low
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
medici-finance/assay#7259 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno