From 23718dc707fbea7ffd97dd5436ae93842a66e15b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Budai?= Date: Tue, 29 Aug 2023 14:48:51 +0200 Subject: [PATCH] upload/oci: fix a crash when the uploader returns an empty response MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit resp.IsResumable crashes if resp.MultipartUploadResponse == nil. This happens for instance when authentication fails. Fix this by also checking the MultipartUploadResponse field. Signed-off-by: Ondřej Budai --- internal/upload/oci/upload.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/internal/upload/oci/upload.go b/internal/upload/oci/upload.go index 45411092d..a8eacc1b6 100644 --- a/internal/upload/oci/upload.go +++ b/internal/upload/oci/upload.go @@ -77,7 +77,9 @@ func (c Client) uploadToBucket(objectName string, bucketName string, namespace s ctx := context.Background() resp, err := uploadManager.UploadFile(ctx, req) if err != nil { - if resp.IsResumable() { + // resp.IsResumable crashes if resp.MultipartUploadResponse == nil + // Thus, we need to check for both. + if resp.MultipartUploadResponse != nil && resp.IsResumable() { resp, err = uploadManager.ResumeUploadFile(ctx, *resp.MultipartUploadResponse.UploadID) if err != nil { return err