From a71e53c8c8b76fc780efc21270accff8fabf5db9 Mon Sep 17 00:00:00 2001 From: Nicola Murino Date: Sun, 23 Mar 2025 11:37:21 +0100 Subject: [PATCH] GCS: properly check for googleapi.Error Fixes #1936 Signed-off-by: Nicola Murino --- internal/vfs/gcsfs.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/internal/vfs/gcsfs.go b/internal/vfs/gcsfs.go index a1b15f97..d34c0a46 100644 --- a/internal/vfs/gcsfs.go +++ b/internal/vfs/gcsfs.go @@ -434,8 +434,9 @@ func (*GCSFs) IsNotExist(err error) bool { if err == storage.ErrObjectNotExist || err == storage.ErrBucketNotExist { return true } - if e, ok := err.(*googleapi.Error); ok { - if e.Code == http.StatusNotFound { + var apiErr *googleapi.Error + if errors.As(err, &apiErr) { + if apiErr.Code == http.StatusNotFound { return true } } @@ -448,8 +449,9 @@ func (*GCSFs) IsPermission(err error) bool { if err == nil { return false } - if e, ok := err.(*googleapi.Error); ok { - if e.Code == http.StatusForbidden || e.Code == http.StatusUnauthorized { + var apiErr *googleapi.Error + if errors.As(err, &apiErr) { + if apiErr.Code == http.StatusForbidden || apiErr.Code == http.StatusUnauthorized { return true } }