Fix application crash when SharePoint displayName is being withheld when using --get-O365-drive-id (#1445)

* Handle bad ShaprePoint data when the API does not return the expected data points when using those references to display what SharePoint sites are available when using --get-O365-drive-id
This commit is contained in:
abraunegg 2021-05-10 08:04:14 +10:00 committed by GitHub
parent c9ca00466a
commit b0771f79e1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -5696,8 +5696,21 @@ final class SyncEngine
// Add to siteSearchResults so we can display what we did find
string siteSearchResultsEntry;
foreach (searchResult; siteQuery["value"].array) {
siteSearchResultsEntry = " * " ~ searchResult["displayName"].str;
siteSearchResults ~= siteSearchResultsEntry;
// We can only add the displayName if it is available
if ("displayName" in searchResult) {
// Use the displayName
siteSearchResultsEntry = " * " ~ searchResult["displayName"].str;
siteSearchResults ~= siteSearchResultsEntry;
} else {
// Add, but indicate displayName unavailable, use id
if ("id" in searchResult) {
siteSearchResultsEntry = " * " ~ "Unknown displayName (Data not provided by API), Site ID: " ~ searchResult["id"].str;
siteSearchResults ~= siteSearchResultsEntry;
} else {
// displayName and id unavailable, display in debug log the entry
log.vdebug("Bad SharePoint Data for site: ", searchResult);
}
}
}
}
} else {