diff --git a/src/internal/m365/graph/errors.go b/src/internal/m365/graph/errors.go index f0df6b4ec..c8dd5aefa 100644 --- a/src/internal/m365/graph/errors.go +++ b/src/internal/m365/graph/errors.go @@ -65,12 +65,13 @@ const ( IOErrDuringRead errorMessage = "IO error during request payload read" MysiteURLNotFound errorMessage = "unable to retrieve user's mysite url" MysiteNotFound errorMessage = "user's mysite not found" + FileNotFound errorMessage = "404 FILE NOT FOUND" NoSPLicense errorMessage = "Tenant does not have a SPO license" ) const ( LabelsMalware = "malware_detected" - LabelsMysiteNotFound = "mysite_not_found" + LabelsDriveNotFound = "drive_not_found" LabelsNoSharePointLicense = "no_sharepoint_license" // LabelsSkippable is used to determine if an error is skippable @@ -316,7 +317,8 @@ func stackReq( } // Checks for the following conditions and labels the error accordingly: -// * mysiteNotFound | mysiteURLNotFound +// * MysiteNotFound | MysiteURLNotFound | FileNotFound +// * NoSPLicense // * malware func setLabels(err *clues.Err, msg string) *clues.Err { if err == nil { @@ -326,8 +328,9 @@ func setLabels(err *clues.Err, msg string) *clues.Err { f := filters.Contains([]string{msg}) if f.Compare(string(MysiteNotFound)) || - f.Compare(string(MysiteURLNotFound)) { - err = err.Label(LabelsMysiteNotFound) + f.Compare(string(MysiteURLNotFound)) || + f.Compare(string(FileNotFound)) { + err = err.Label(LabelsDriveNotFound) } if f.Compare(string(NoSPLicense)) { diff --git a/src/internal/m365/graph/errors_test.go b/src/internal/m365/graph/errors_test.go index 81d9787bb..4c981b9ba 100644 --- a/src/internal/m365/graph/errors_test.go +++ b/src/internal/m365/graph/errors_test.go @@ -552,12 +552,17 @@ func (suite *GraphErrorsUnitSuite) TestGraphStack_labels() { { name: "mysite not found", err: odErrMsg("code", string(MysiteNotFound)), - expect: []string{LabelsMysiteNotFound}, + expect: []string{LabelsDriveNotFound}, }, { name: "mysite url not found", err: odErrMsg("code", string(MysiteURLNotFound)), - expect: []string{LabelsMysiteNotFound}, + expect: []string{LabelsDriveNotFound}, + }, + { + name: "404 file not found", + err: odErrMsg("code", string(FileNotFound)), + expect: []string{LabelsDriveNotFound}, }, { name: "no sp license", diff --git a/src/pkg/services/m365/api/drive_pager.go b/src/pkg/services/m365/api/drive_pager.go index 3ba6e4b46..b2d77085e 100644 --- a/src/pkg/services/m365/api/drive_pager.go +++ b/src/pkg/services/m365/api/drive_pager.go @@ -398,7 +398,8 @@ func GetAllDrives( for i := 0; i <= maxRetryCount; i++ { page, err = pager.GetPage(ctx) if err != nil { - if clues.HasLabel(err, graph.LabelsMysiteNotFound) || clues.HasLabel(err, graph.LabelsNoSharePointLicense) { + if clues.HasLabel(err, graph.LabelsDriveNotFound) || + clues.HasLabel(err, graph.LabelsNoSharePointLicense) { logger.CtxErr(ctx, err).Infof("resource owner does not have a drive") return make([]models.Driveable, 0), nil // no license or drives. } diff --git a/src/pkg/services/m365/api/users.go b/src/pkg/services/m365/api/users.go index 728e1f466..04a4140f6 100644 --- a/src/pkg/services/m365/api/users.go +++ b/src/pkg/services/m365/api/users.go @@ -182,7 +182,7 @@ func (c Users) GetInfo(ctx context.Context, userID string) (*UserInfo, error) { // check whether the user is able to access their onedrive drive. // if they cannot, we can assume they are ineligible for onedrive backups. if _, err := c.GetDefaultDrive(ctx, userID); err != nil { - if !clues.HasLabel(err, graph.LabelsMysiteNotFound) && !clues.HasLabel(err, graph.LabelsNoSharePointLicense) { + if !clues.HasLabel(err, graph.LabelsDriveNotFound) && !clues.HasLabel(err, graph.LabelsNoSharePointLicense) { logger.CtxErr(ctx, err).Error("getting user's default drive") return nil, graph.Wrap(ctx, err, "getting user's default drive info") } diff --git a/src/pkg/services/m365/m365.go b/src/pkg/services/m365/m365.go index 91141696f..8f8a6685a 100644 --- a/src/pkg/services/m365/m365.go +++ b/src/pkg/services/m365/m365.go @@ -107,7 +107,8 @@ func checkUserHasDrives(ctx context.Context, dgdd getDefaultDriver, userID strin if err != nil { // we consider this a non-error case, since it // answers the question the caller is asking. - if clues.HasLabel(err, graph.LabelsMysiteNotFound) || clues.HasLabel(err, graph.LabelsNoSharePointLicense) { + if clues.HasLabel(err, graph.LabelsDriveNotFound) || + clues.HasLabel(err, graph.LabelsNoSharePointLicense) { return false, nil }