scm_pr_merged never fires for a pull request merged while a sync is running
Les mainteneurs répondent en général sous 1 jour
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 3/5
- Temps estimé
- 1-2 jours
- Accessibilité débutants
- 64/100
Piste de recherche
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.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
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.
- Langage dominant
- Go
- Étoiles
- 421
- Forks
- 50
- Merge moyen
- 17 h 34 min
- PR mergées (30 j)
- 80
Préparer son environnement
- Fournit un Dockerfile ou un fichier Docker Compose
- Aucun modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de Windshiftapp/core
-
Difficulté 2/5 1-3 heures Accessibilité débutants 66/100
Windshiftapp/core#542 ·
Les mainteneurs répondent en général sous 1 jour
-
Time Tracking FilteringOuverte
Difficulté 2/5 1-3 heures Accessibilité débutants 64/100
Windshiftapp/core#334 · 2 commentaires ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
Windshiftapp/core#259 · 1 commentaire · 1 réaction ·
Les mainteneurs répondent en général sous 1 jour
-
[Bug][AI chat] Select menu dont appear when on index pagePeut-être pris @valentimarco l’a pris aujourd’hui. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 20/100
Windshiftapp/core#541 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 3/5 1-2 jours Accessibilité débutants 45/100
Windshiftapp/core#538 · 1 réaction ·
Les mainteneurs répondent en général sous 1 jour
Toutes les issues de Windshiftapp/core
Issues similaires
-
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
karmada-io/karmada#8101 ·
Les mainteneurs répondent en général sous 1 jour
-
product:platform
Difficulté 2/5 1-3 heures Accessibilité débutants 77/100
Infisical/infisical#9746 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
CrossEntropyFilter raises on zero probabilities and single-class resultsPeut-être pris @NopeCharon l’a pris aujourd’hui. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
Les mainteneurs répondent en général sous 1 jour
-
bug
Difficulté 2/5 1-3 heures Accessibilité débutants 86/100
txn2/mcp-data-platform#2728 ·
Les mainteneurs répondent en général sous 1 jour
-
effort:s impact:low raised-by:worker risk:low
Difficulté 2/5 1-3 heures Accessibilité débutants 70/100
medici-finance/assay#7259 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour