Skip to content

Commit fd4ee72

Browse files
authored
Apply hotfix to main (#12338)
1 parent faf9d09 commit fd4ee72

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

common

readthedocs/doc_builder/environments.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
from docker.errors import NotFound as DockerNotFoundError
1717
from requests.exceptions import ConnectionError
1818
from requests.exceptions import ReadTimeout
19+
from slumber.exceptions import HttpNotFoundError
1920

2021
from readthedocs.builds.models import BuildCommandResultMixin
2122
from readthedocs.core.utils import slugify
@@ -269,7 +270,16 @@ def save(self, api_client):
269270
# If the command has an id, it means it has been saved before,
270271
# so we update it instead of creating a new one.
271272
if self.id:
272-
resp = api_client.command(self.id).patch(data)
273+
try:
274+
resp = api_client.command(self.id).patch(data)
275+
except HttpNotFoundError:
276+
# TODO don't do this, address builds restarting instead.
277+
# We try to post the buildcommand again as a temporary fix
278+
# for projects that restart the build process. There seems to be
279+
# something that causes a 404 during `patch()` in some biulds,
280+
# so we assume retrying `post()` for the build command is okay.
281+
log.exception("Build command has an id but doesn't exist in the database.")
282+
resp = api_client.command.post(data)
273283
else:
274284
resp = api_client.command.post(data)
275285

0 commit comments

Comments
 (0)