From 2662411b96f51d7ba3fcf992f6f307105d89ebb2 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Thu, 13 Jun 2024 07:55:42 +0200 Subject: [PATCH] [FIX] runbot_merge: `_schedule_fp_followup` not handling multiple batches `_schedule_fp_followup` correctly iterates on `self`, however some of the per-iteration work did not handle that correctly, and would try to access fields on `self`. Thankfully in most cases it only works on one batch at a time anyway, *however* if multiple PRs share a HEAD (which is weird but...) then `_validate` is called on multiple PRs, which through the forwardport override leads to `_schedule_fp_followup` being called on multiple batches, and failing when trying to access the `fw_policy`. Fix by avoiding the misuse of `self` in the two locations where it's doing something other than accessing `env`. --- runbot_merge/models/batch.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/runbot_merge/models/batch.py b/runbot_merge/models/batch.py index 00886b1d..fbca57fc 100644 --- a/runbot_merge/models/batch.py +++ b/runbot_merge/models/batch.py @@ -427,7 +427,7 @@ class Batch(models.Model): if not (batch.parent_id and all(p.parent_id for p in batch.prs)): _logger.info('-> no parent %s (%s)', batch, prs) continue - if not self.env.context.get('force_fw') and self.source.fw_policy != 'skipci' \ + if not self.env.context.get('force_fw') and batch.source.fw_policy != 'skipci' \ and (invalid := batch.prs.filtered(lambda p: p.state not in ['validated', 'ready'])): _logger.info( '-> wrong state %s (%s)', @@ -437,7 +437,7 @@ class Batch(models.Model): continue # check if we've already forward-ported this branch - next_target = self._find_next_targets() + next_target = batch._find_next_targets() if not next_target: _logger.info("-> forward port done (no next target)") continue