Compare commits
1 Commits
main
...
drive_404_
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
976cd0140e |
@ -65,12 +65,13 @@ const (
|
|||||||
IOErrDuringRead errorMessage = "IO error during request payload read"
|
IOErrDuringRead errorMessage = "IO error during request payload read"
|
||||||
MysiteURLNotFound errorMessage = "unable to retrieve user's mysite url"
|
MysiteURLNotFound errorMessage = "unable to retrieve user's mysite url"
|
||||||
MysiteNotFound errorMessage = "user's mysite not found"
|
MysiteNotFound errorMessage = "user's mysite not found"
|
||||||
|
FileNotFound errorMessage = "404 FILE NOT FOUND"
|
||||||
NoSPLicense errorMessage = "Tenant does not have a SPO license"
|
NoSPLicense errorMessage = "Tenant does not have a SPO license"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
LabelsMalware = "malware_detected"
|
LabelsMalware = "malware_detected"
|
||||||
LabelsMysiteNotFound = "mysite_not_found"
|
LabelsDriveNotFound = "drive_not_found"
|
||||||
LabelsNoSharePointLicense = "no_sharepoint_license"
|
LabelsNoSharePointLicense = "no_sharepoint_license"
|
||||||
|
|
||||||
// LabelsSkippable is used to determine if an error is skippable
|
// 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:
|
// Checks for the following conditions and labels the error accordingly:
|
||||||
// * mysiteNotFound | mysiteURLNotFound
|
// * MysiteNotFound | MysiteURLNotFound | FileNotFound
|
||||||
|
// * NoSPLicense
|
||||||
// * malware
|
// * malware
|
||||||
func setLabels(err *clues.Err, msg string) *clues.Err {
|
func setLabels(err *clues.Err, msg string) *clues.Err {
|
||||||
if err == nil {
|
if err == nil {
|
||||||
@ -326,8 +328,9 @@ func setLabels(err *clues.Err, msg string) *clues.Err {
|
|||||||
f := filters.Contains([]string{msg})
|
f := filters.Contains([]string{msg})
|
||||||
|
|
||||||
if f.Compare(string(MysiteNotFound)) ||
|
if f.Compare(string(MysiteNotFound)) ||
|
||||||
f.Compare(string(MysiteURLNotFound)) {
|
f.Compare(string(MysiteURLNotFound)) ||
|
||||||
err = err.Label(LabelsMysiteNotFound)
|
f.Compare(string(FileNotFound)) {
|
||||||
|
err = err.Label(LabelsDriveNotFound)
|
||||||
}
|
}
|
||||||
|
|
||||||
if f.Compare(string(NoSPLicense)) {
|
if f.Compare(string(NoSPLicense)) {
|
||||||
|
|||||||
@ -552,12 +552,17 @@ func (suite *GraphErrorsUnitSuite) TestGraphStack_labels() {
|
|||||||
{
|
{
|
||||||
name: "mysite not found",
|
name: "mysite not found",
|
||||||
err: odErrMsg("code", string(MysiteNotFound)),
|
err: odErrMsg("code", string(MysiteNotFound)),
|
||||||
expect: []string{LabelsMysiteNotFound},
|
expect: []string{LabelsDriveNotFound},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "mysite url not found",
|
name: "mysite url not found",
|
||||||
err: odErrMsg("code", string(MysiteURLNotFound)),
|
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",
|
name: "no sp license",
|
||||||
|
|||||||
@ -398,7 +398,8 @@ func GetAllDrives(
|
|||||||
for i := 0; i <= maxRetryCount; i++ {
|
for i := 0; i <= maxRetryCount; i++ {
|
||||||
page, err = pager.GetPage(ctx)
|
page, err = pager.GetPage(ctx)
|
||||||
if err != nil {
|
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")
|
logger.CtxErr(ctx, err).Infof("resource owner does not have a drive")
|
||||||
return make([]models.Driveable, 0), nil // no license or drives.
|
return make([]models.Driveable, 0), nil // no license or drives.
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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.
|
// check whether the user is able to access their onedrive drive.
|
||||||
// if they cannot, we can assume they are ineligible for onedrive backups.
|
// if they cannot, we can assume they are ineligible for onedrive backups.
|
||||||
if _, err := c.GetDefaultDrive(ctx, userID); err != nil {
|
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")
|
logger.CtxErr(ctx, err).Error("getting user's default drive")
|
||||||
return nil, graph.Wrap(ctx, err, "getting user's default drive info")
|
return nil, graph.Wrap(ctx, err, "getting user's default drive info")
|
||||||
}
|
}
|
||||||
|
|||||||
@ -107,7 +107,8 @@ func checkUserHasDrives(ctx context.Context, dgdd getDefaultDriver, userID strin
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
// we consider this a non-error case, since it
|
// we consider this a non-error case, since it
|
||||||
// answers the question the caller is asking.
|
// 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
|
return false, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user