Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix retrieving error detail in Get-UPABulkImportStatus #3494

Merged
merged 2 commits into from
Oct 13, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions src/Commands/UserProfiles/GetUPABulkImportStatus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ private void GetErrorInfo(ImportProfilePropertiesJobInfo job)
{
var webUrl = Web.GetWebUrlFromPageUrl(AdminContext, job.LogFolderUri);
AdminContext.ExecuteQueryRetry();
string relativePath = job.LogFolderUri.Replace(webUrl.Value, "");
string relativePath = new Uri(job.LogFolderUri).LocalPath;
var webCtx = AdminContext.Clone(webUrl.Value);
if (webCtx.Web.DoesFolderExists(relativePath))
{
Expand All @@ -60,9 +60,22 @@ private void GetErrorInfo(ImportProfilePropertiesJobInfo job)
string message = string.Empty;
foreach (var logFile in files)
message += "\r\n" + webCtx.Web.GetFileAsString(logFile.ServerRelativeUrl);
job.ErrorMessage = message;
TrySetJobErrorMessage(job, message);
}
}
}

private void TrySetJobErrorMessage(ImportProfilePropertiesJobInfo job, string message)
{
try
{
job.ErrorMessage = message;
}
catch (ClientRequestException)
{
// Setting the ErrorMessage property to ImportProfilePropertiesJobInfo returned by GetImportProfilePropertyJobs() throws an exception sometimes as the Path is property is null.
// In this case the generic error message with the file location of the log in SPO will be returned.
}
}
}
}