From 2e68793f347d01f9a73a6dcff13f3cf496f07aac Mon Sep 17 00:00:00 2001 From: Foteini Giouleka Date: Mon, 31 Jul 2023 08:14:51 +0300 Subject: [PATCH] Poling translations infinite loop fix If downloading translations fails due to reasons such as the inability to create the downloaded file the "redirect" field in the response is empty and status is falied Based on backoff functionality, a request will be retried after 1s, 1s, 1s, 2s, 3s, 5s, 8s, 13s and then after 13s forever To avoid this we can break the loop if status of task is failed Remove retries --- pkg/txapi/resource_translations_async_downloads.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pkg/txapi/resource_translations_async_downloads.go b/pkg/txapi/resource_translations_async_downloads.go index 28f9554..69c6b32 100644 --- a/pkg/txapi/resource_translations_async_downloads.go +++ b/pkg/txapi/resource_translations_async_downloads.go @@ -49,6 +49,11 @@ func PollTranslationDownload(download *jsonapi.Resource, filePath string) error } if download.Redirect != "" { break + } else if download.Attributes["status"] == "failed" { + return fmt.Errorf( + "download of translation '%s' failed", + download.Relationships["resource"].DataSingular.Id, + ) } } resp, err := http.Get(download.Redirect)