Skip to content
This repository was archived by the owner on Nov 1, 2023. It is now read-only.

Commit 162a30a

Browse files
committed
PR comments
1 parent f01243f commit 162a30a

File tree

2 files changed

+7
-40
lines changed

2 files changed

+7
-40
lines changed

src/ApiService/ApiService/onefuzzlib/NotificationOperations.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ public async Async.Task<OneFuzzResult<Notification>> Create(Container container,
134134
if (await _context.FeatureManagerSnapshot.IsEnabledAsync(FeatureFlagConstants.SemanticNotificationConfigValidation)) {
135135
var validConfig = await config.Validate();
136136
if (!validConfig.IsOk) {
137-
_logTracer.LogError("Error(s) ocurred during template validation: {title}\r\n{errors}", validConfig.ErrorV.Title, string.Join("\r\n", validConfig.ErrorV.Errors ?? new()));
137+
_logTracer.LogError($"Error(s) ocurred during template validation: {{title}}{Environment.NewLine}{{errors}}", validConfig.ErrorV.Title, string.Join(Environment.NewLine, validConfig.ErrorV.Errors ?? new()));
138138
return OneFuzzResult<Notification>.Error(validConfig.ErrorV);
139139
}
140140
}

src/ApiService/ApiService/onefuzzlib/notifications/Ado.cs

Lines changed: 6 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,9 @@ private static bool IsTransient(Exception e) {
9090
}
9191

9292
private static async Async.Task<OneFuzzResultVoid> ValidatePath(string project, string path, TreeStructureGroup structureGroup, WorkItemTrackingHttpClient client) {
93+
var pathType = (structureGroup == TreeStructureGroup.Areas) ? "Area" : "Iteration";
9394
var pathParts = path.Split('\\');
94-
if (pathParts[0] != project) {
95+
if (!string.Equals(pathParts[0], project, StringComparison.OrdinalIgnoreCase)) {
9596
return OneFuzzResultVoid.Error(ErrorCode.ADO_VALIDATION_INVALID_PATH, new string[] {
9697
$"Path \"{path}\" is invalid. It must start with the project name, \"{project}\".",
9798
$"Example: \"{project}\\{path}\".",
@@ -101,15 +102,15 @@ private static async Async.Task<OneFuzzResultVoid> ValidatePath(string project,
101102
var current = await client.GetClassificationNodeAsync(project, structureGroup, depth: pathParts.Length - 1);
102103
if (current == null) {
103104
return OneFuzzResultVoid.Error(ErrorCode.ADO_VALIDATION_INVALID_PATH, new string[] {
104-
$"Path \"{path}\" is invalid. \"{project}\" is not a valid project.",
105+
$"{pathType} Path \"{path}\" is invalid. \"{project}\" is not a valid project.",
105106
});
106107
}
107108

108109
foreach (var part in pathParts.Skip(1)) {
109-
var child = current.Children?.FirstOrDefault(x => x.Name == part);
110+
var child = current.Children?.FirstOrDefault(x => string.Equals(x.Name, part, StringComparison.OrdinalIgnoreCase));
110111
if (child == null) {
111112
return OneFuzzResultVoid.Error(ErrorCode.ADO_VALIDATION_INVALID_PATH, new string[] {
112-
$"Path \"{path}\" is invalid. \"{part}\" is not a valid child of \"{current.Name}\".",
113+
$"{pathType} Path \"{path}\" is invalid. \"{part}\" is not a valid child of \"{current.Name}\".",
113114
$"Valid children of \"{current.Name}\" are: [{string.Join(',', current.Children?.Select(x => $"\"{x.Name}\"") ?? new List<string>())}].",
114115
});
115116
}
@@ -192,61 +193,27 @@ await policy.ExecuteAsync(async () => {
192193
});
193194
}
194195

195-
// Validate AreaPath exists
196196
try {
197+
// Validate AreaPath and IterationPath exist
197198
if (config.AdoFields.TryGetValue("System.AreaPath", out var areaPathString)) {
198199
var validateAreaPath = await ValidatePath(config.Project, areaPathString, TreeStructureGroup.Areas, witClient);
199200
if (!validateAreaPath.IsOk) {
200201
return validateAreaPath;
201202
}
202203
}
203-
} catch (VssUnauthorizedException e) {
204-
return OneFuzzResultVoid.Error(ErrorCode.ADO_VALIDATION_INVALID_PAT, new string[] {
205-
"The provided PAT may be missing scopes. We were able to connect with it but unable to validate the fields.",
206-
"Please check the configured scopes.",
207-
$"Exception: {e}"
208-
});
209-
} catch (VssAuthenticationException e) {
210-
return OneFuzzResultVoid.Error(ErrorCode.ADO_VALIDATION_INVALID_PAT, new string[] {
211-
"The provided PAT may be missing scopes. We were able to connect with it but unable to validate the fields.",
212-
"Please check the configured scopes.",
213-
$"Exception: {e}"
214-
});
215-
} catch (Exception e) {
216-
return OneFuzzResultVoid.Error(ErrorCode.ADO_VALIDATION_UNEXPECTED_ERROR, new string[] {
217-
"Failed to query and validate against the classification nodes for this project",
218-
$"Exception: {e}",
219-
});
220-
}
221-
222-
// Validate IterationPath exists
223-
try {
224204
if (config.AdoFields.TryGetValue("System.IterationPath", out var iterationPathString)) {
225205
var validateIterationPath = await ValidatePath(config.Project, iterationPathString, TreeStructureGroup.Iterations, witClient);
226206
if (!validateIterationPath.IsOk) {
227207
return validateIterationPath;
228208
}
229209
}
230-
} catch (VssUnauthorizedException e) {
231-
return OneFuzzResultVoid.Error(ErrorCode.ADO_VALIDATION_INVALID_PAT, new string[] {
232-
"The provided PAT may be missing scopes. We were able to connect with it but unable to validate the fields.",
233-
"Please check the configured scopes.",
234-
$"Exception: {e}"
235-
});
236-
} catch (VssAuthenticationException e) {
237-
return OneFuzzResultVoid.Error(ErrorCode.ADO_VALIDATION_INVALID_PAT, new string[] {
238-
"The provided PAT may be missing scopes. We were able to connect with it but unable to validate the fields.",
239-
"Please check the configured scopes.",
240-
$"Exception: {e}"
241-
});
242210
} catch (Exception e) {
243211
return OneFuzzResultVoid.Error(ErrorCode.ADO_VALIDATION_UNEXPECTED_ERROR, new string[] {
244212
"Failed to query and validate against the classification nodes for this project",
245213
$"Exception: {e}",
246214
});
247215
}
248216

249-
250217
return OneFuzzResultVoid.Ok;
251218
}
252219

0 commit comments

Comments
 (0)