From b112d7458c808c7d01f54afdab2f06ccae706368 Mon Sep 17 00:00:00 2001 From: Victor Elias Date: Fri, 24 Mar 2023 11:19:00 -0300 Subject: [PATCH] task: Make 4xx errors from Catalyst unretriable (#175) * task: Make 4xx errors from Catalyst unretriable This is to improve our error classification and both not retry as well as not alert from user-input errors on the request to Catalyst (normally bad input URLs). * clients: Remove error forcing, return RateLimited instead --- clients/catalyst.go | 6 ++++++ task/upload.go | 2 ++ 2 files changed, 8 insertions(+) diff --git a/clients/catalyst.go b/clients/catalyst.go index 301ca6b2..2f115339 100644 --- a/clients/catalyst.go +++ b/clients/catalyst.go @@ -164,3 +164,9 @@ func isTooManyRequestsErr(err error) bool { var statusErr *HTTPStatusError return errors.As(err, &statusErr) && statusErr.Status == http.StatusTooManyRequests } + +func IsInputError(err error) bool { + var statusErr *HTTPStatusError + return errors.As(err, &statusErr) && + (statusErr.Status >= 400 && statusErr.Status < 500) +} diff --git a/task/upload.go b/task/upload.go index 2c69d1b8..89440849 100644 --- a/task/upload.go +++ b/task/upload.go @@ -83,6 +83,8 @@ func handleUploadVOD(p handleUploadVODParams) (*TaskHandlerOutput, error) { err = tctx.catalyst.UploadVOD(ctx, req) if errors.Is(err, clients.ErrRateLimited) { nextStep = "rateLimitBackoff" + } else if clients.IsInputError(err) { + return nil, UnretriableError{fmt.Errorf("input error on catalyst request: %w", err)} } else if err != nil { return nil, fmt.Errorf("failed to call catalyst: %w", err) }