Skip to content

Commit 587e1f3

Browse files
authored
Merge pull request #5678 from stsewd/fix-bug-in-notifications
Fix bug in notifications
2 parents 1e4a46b + a684b32 commit 587e1f3

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

readthedocs/projects/tasks.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ def run(
387387
return False
388388

389389
# Catch unhandled errors in the setup step
390-
except Exception as e: # noqa
390+
except Exception:
391391
log.exception(
392392
'An unhandled exception was raised during build setup',
393393
extra={
@@ -411,14 +411,14 @@ def run(
411411
self.setup_env.update_build(BUILD_STATE_FINISHED)
412412

413413
# Send notifications for unhandled errors
414-
self.send_notifications()
414+
self.send_notifications(version_pk, build_pk)
415415
return False
416416
else:
417417
# No exceptions in the setup step, catch unhandled errors in the
418418
# build steps
419419
try:
420420
self.run_build(docker=docker, record=record)
421-
except Exception as e: # noqa
421+
except Exception:
422422
log.exception(
423423
'An unhandled exception was raised during project build',
424424
extra={
@@ -439,7 +439,7 @@ def run(
439439
self.build_env.update_build(BUILD_STATE_FINISHED)
440440

441441
# Send notifications for unhandled errors
442-
self.send_notifications()
442+
self.send_notifications(version_pk, build_pk)
443443
return False
444444

445445
return True
@@ -497,7 +497,7 @@ def run_setup(self, record=True):
497497
# triggered before the previous one has finished (e.g. two webhooks,
498498
# one after the other)
499499
if not isinstance(self.setup_env.failure, VersionLockedError):
500-
self.send_notifications()
500+
self.send_notifications(self.version.pk, self.build['id'])
501501

502502
return False
503503

@@ -566,15 +566,14 @@ def run_build(self, docker, record):
566566
# TODO the build object should have an idea of these states,
567567
# extend the model to include an idea of these outcomes
568568
outcomes = self.build_docs()
569-
build_id = self.build.get('id')
570569
except vcs_support_utils.LockTimeout as e:
571570
self.task.retry(exc=e, throw=False)
572571
raise VersionLockedError
573572
except SoftTimeLimitExceeded:
574573
raise BuildTimeoutError
575574

576575
# Finalize build and update web servers
577-
if build_id:
576+
if self.build.get('id'):
578577
self.update_app_instances(
579578
html=bool(outcomes['html']),
580579
search=bool(outcomes['search']),
@@ -586,7 +585,7 @@ def run_build(self, docker, record):
586585
log.warning('No build ID, not syncing files')
587586

588587
if self.build_env.failed:
589-
self.send_notifications()
588+
self.send_notifications(self.version.pk, self.build['id'])
590589

591590
build_complete.send(sender=Build, build=self.build_env.build)
592591

@@ -920,9 +919,9 @@ def build_docs_class(self, builder_class):
920919
builder.move()
921920
return success
922921

923-
def send_notifications(self):
922+
def send_notifications(self, version_pk, build_pk):
924923
"""Send notifications on build failure."""
925-
send_notifications.delay(self.version.pk, build_pk=self.build['id'])
924+
send_notifications.delay(version_pk, build_pk=build_pk)
926925

927926
def is_type_sphinx(self):
928927
"""Is documentation type Sphinx."""

0 commit comments

Comments
 (0)