From e2dca17e423f016d05a1329205afef5ccc2ce817 Mon Sep 17 00:00:00 2001 From: Christophe Monniez Date: Mon, 13 Feb 2023 14:16:28 +0100 Subject: [PATCH] [FIX] runbot: avoid traceback when forcing a preparing batch When forcing a new batch on a bundle the _force method does not return a batch leading to a traceback in the force_bundle route. --- runbot/controllers/frontend.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/runbot/controllers/frontend.py b/runbot/controllers/frontend.py index 8969be69..95e82e71 100644 --- a/runbot/controllers/frontend.py +++ b/runbot/controllers/frontend.py @@ -210,9 +210,10 @@ class Runbot(Controller): def force_bundle(self, bundle, auto_rebase=False, **_post): _logger.info('user %s forcing bundle %s', request.env.user.name, bundle.name) # user must be able to read bundle batch = bundle.sudo()._force() - batch._log('Batch forced by %s', request.env.user.name) - batch._prepare(auto_rebase) - return werkzeug.utils.redirect('/runbot/batch/%s' % batch.id) + if batch: + batch._log('Batch forced by %s', request.env.user.name) + batch._prepare(auto_rebase) + return werkzeug.utils.redirect('/runbot/batch/%s' % batch.id) @route(['/runbot/batch/'], website=True, auth='public', type='http', sitemap=False) def batch(self, batch_id=None, **kwargs):