diff --git a/CHANGELOG.md b/CHANGELOG.md index 06d7a09ed..8677a27b1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] (beta) +### Fixed +- SharePoint backup would fail if any site had an empty display name + +## [v0.14.2] (beta) - 2023-10-17 + ### Added - Skips graph calls for expired item download URLs. - Export operation now shows the stats at the end of the run diff --git a/src/pkg/services/m365/api/sites.go b/src/pkg/services/m365/api/sites.go index 94abfb8c7..10735c19a 100644 --- a/src/pkg/services/m365/api/sites.go +++ b/src/pkg/services/m365/api/sites.go @@ -273,21 +273,20 @@ func ValidateSite(item models.Siteable) error { return clues.New("missing webURL").With("site_id", clues.Hide(id)) } + // TODO(ashmrtn): Personal and search site checks should really be in the + // caller instead of the validation function. // personal (ie: oneDrive) sites have to be filtered out server-side. if strings.Contains(wURL, PersonalSitePath) { return clues.Stack(ErrKnownSkippableCase). With("site_id", clues.Hide(id), "site_web_url", clues.Hide(wURL)) } - name := ptr.Val(item.GetDisplayName()) - if len(name) == 0 { - // the built-in site at "https://{tenant-domain}/search" never has a name. - if strings.HasSuffix(wURL, "/search") { - return clues.Stack(ErrKnownSkippableCase). - With("site_id", clues.Hide(id), "site_web_url", clues.Hide(wURL)) - } - - return clues.New("missing site display name").With("site_id", clues.Hide(id)) + // Not checking for a name since it's possible to have sites without a name. + // Do check if it's the search site though since we want to filter that out. + // The built-in site at "https://{tenant-domain}/search" never has a name. + if len(ptr.Val(item.GetDisplayName())) == 0 && strings.HasSuffix(wURL, "/search") { + return clues.Stack(ErrKnownSkippableCase). + With("site_id", clues.Hide(id), "site_web_url", clues.Hide(wURL)) } return nil diff --git a/src/pkg/services/m365/api/sites_test.go b/src/pkg/services/m365/api/sites_test.go index ada517c92..3f0d24554 100644 --- a/src/pkg/services/m365/api/sites_test.go +++ b/src/pkg/services/m365/api/sites_test.go @@ -61,7 +61,7 @@ func (suite *SitesUnitSuite) TestValidateSite() { s.SetWebUrl(ptr.To("sharepoint.com/sites/foo")) return s }(), - errCheck: assert.Error, + errCheck: assert.NoError, }, { name: "Search site", @@ -136,6 +136,7 @@ func (suite *SitesIntgSuite) TestGetAll() { for _, site := range sites { assert.NotContains(t, ptr.Val(site.GetWebUrl()), api.PersonalSitePath, "must not return onedrive sites") + assert.NotContains(t, ptr.Val(site.GetWebUrl()), "sharepoint.com/search", "must not return search site") } }