Skip to content

Commit ac37f53

Browse files
committed
projects: don't explode trying to update UpdateDocsTaskStep state
If we don't have it because setup_env hasn't been called yet. Traceback (most recent call last): File "/readthedocs/projects/tasks.py", line 313, in run self.version = self.get_version(self.project, version_pk) File "/readthedocs/projects/tasks.py", line 84, in get_version version_data = api_v2.version(version_pk).get() File "/lib/python3.5/site-packages/slumber/__init__.py", line 155, in get resp = self._request("GET", params=kwargs) File "/lib/python3.5/site-packages/slumber/__init__.py", line 101, in _request raise exception_class("Client Error %s: %s" % (resp.status_code, url), response=resp, content=resp.content) slumber.exceptions.HttpNotFoundError: Client Error 404: http://localhost:8002/api/v2/version/868/ During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/docsitalia/management/commands/rebuild_projects.py", line 33, in handle task.run(version.project.pk, version_pk=version.pk, build_pk=build.pk) File "/readthedocs/projects/tasks.py", line 332, in run build_id=build_pk, AttributeError: 'UpdateDocsTaskStep' object has no attribute 'setup_env' While at it do the same for build_env that may be not set if run_build fail early.
1 parent ae9a6d3 commit ac37f53

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

readthedocs/projects/tasks.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,7 @@ def __init__(self, build_env=None, python_env=None, config=None,
286286
if config is not None:
287287
self.config = config
288288
self.task = task
289+
self.setup_env = None
289290

290291
def _log(self, msg):
291292
log.info(LOG_TEMPLATE
@@ -355,12 +356,13 @@ def run(self, pk, version_pk=None, build_pk=None, record=True,
355356
},
356357
},
357358
)
358-
self.setup_env.failure = BuildEnvironmentError(
359-
BuildEnvironmentError.GENERIC_WITH_BUILD_ID.format(
360-
build_id=build_pk,
359+
if self.setup_env is not None:
360+
self.setup_env.failure = BuildEnvironmentError(
361+
BuildEnvironmentError.GENERIC_WITH_BUILD_ID.format(
362+
build_id=build_pk,
363+
)
361364
)
362-
)
363-
self.setup_env.update_build(BUILD_STATE_FINISHED)
365+
self.setup_env.update_build(BUILD_STATE_FINISHED)
364366
return False
365367
else:
366368
# No exceptions in the setup step, catch unhandled errors in the
@@ -379,12 +381,13 @@ def run(self, pk, version_pk=None, build_pk=None, record=True,
379381
},
380382
},
381383
)
382-
self.build_env.failure = BuildEnvironmentError(
383-
BuildEnvironmentError.GENERIC_WITH_BUILD_ID.format(
384-
build_id=build_pk,
384+
if self.build_env is not None:
385+
self.build_env.failure = BuildEnvironmentError(
386+
BuildEnvironmentError.GENERIC_WITH_BUILD_ID.format(
387+
build_id=build_pk,
388+
)
385389
)
386-
)
387-
self.build_env.update_build(BUILD_STATE_FINISHED)
390+
self.build_env.update_build(BUILD_STATE_FINISHED)
388391
return False
389392

390393
return True

0 commit comments

Comments
 (0)