Fix application crash with --get-O365-drive-id when API response is restricted (#1198)

* Check OneDrive API response for required elements before attempting to use elements for next query
This commit is contained in:
abraunegg 2020-12-23 15:25:59 +11:00 committed by GitHub
parent 8c6d1d19b8
commit 62a2b4f393
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -5360,6 +5360,9 @@ final class SyncEngine
foreach (searchResult; siteQuery["value"].array) {
// Need an 'exclusive' match here with o365SharedLibraryName as entered
log.vdebug("Found O365 Site: ", searchResult);
// 'displayName', 'id' and 'webUrl' have to be present in the search result record
if (("displayName" in searchResult) && ("id" in searchResult) && ("webUrl" in searchResult)) {
if (o365SharedLibraryName == searchResult["displayName"].str){
// 'displayName' matches search request
site_id = searchResult["id"].str;
@ -5392,6 +5395,13 @@ final class SyncEngine
return;
}
}
} else {
// 'displayName' not present in JSON results
log.error("ERROR: The results returned from OneDrive API do not contain the required items to match. Please check your permissions with your site administrator.");
log.error("ERROR: Your site security settings is preventing the following details from being accessed: 'displayName', 'id' and 'webUrl'");
log.error("ERROR: To debug this further, please use --verbose --verbose to provide insight as to what details are actually returned.");
return;
}
}
if(!found) {