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

Commit c8938ba

Browse files
committed
Throw exceptoins for missing area/iteration paths
1 parent 4c6fb7a commit c8938ba

File tree

1 file changed

+56
-2
lines changed
  • src/ApiService/ApiService/onefuzzlib/notifications

1 file changed

+56
-2
lines changed

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

Lines changed: 56 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,9 @@ await policy.ExecuteAsync(async () => {
124124
return OneFuzzResultVoid.Error(ErrorCode.ADO_VALIDATION_INVALID_PAT, "Auth token is missing or invalid");
125125
}
126126

127+
var witClient = await connection.GetClientAsync<WorkItemTrackingHttpClient>();
127128
try {
128129
// Validate unique_fields are part of the project's valid fields
129-
var witClient = await connection.GetClientAsync<WorkItemTrackingHttpClient>();
130-
131130
// The set of valid fields for this project according to ADO
132131
var projectValidFields = await GetValidFields(witClient, config.Project);
133132

@@ -162,6 +161,61 @@ await policy.ExecuteAsync(async () => {
162161
});
163162
}
164163

164+
// Validate AreaPath exists
165+
try {
166+
if (config.AdoFields.TryGetValue("System.AreaPath", out var areaPathString)) {
167+
_ = await witClient.GetClassificationNodeAsync(config.Project, TreeStructureGroup.Areas, areaPathString);
168+
}
169+
} catch (VssUnauthorizedException e) {
170+
return OneFuzzResultVoid.Error(ErrorCode.ADO_VALIDATION_INVALID_PAT, new string[] {
171+
$"Failed to connect to {config.BaseUrl} using the provided token",
172+
$"Exception: {e}"
173+
});
174+
} catch (VssAuthenticationException e) {
175+
return OneFuzzResultVoid.Error(ErrorCode.ADO_VALIDATION_INVALID_PAT, new string[] {
176+
$"Failed to connect to {config.BaseUrl} using the provided token",
177+
$"Exception: {e}"
178+
});
179+
} catch (VssServiceException e) {
180+
return OneFuzzResultVoid.Error(ErrorCode.ADO_VALIDATION_UNEXPECTED_ERROR, new string[] {
181+
"AreaPath error",
182+
$"Exception: {e}",
183+
});
184+
} catch (Exception e) {
185+
return OneFuzzResultVoid.Error(ErrorCode.ADO_VALIDATION_UNEXPECTED_ERROR, new string[] {
186+
"Generic AreaPath error",
187+
$"Exception: {e}",
188+
});
189+
}
190+
191+
// Validate IterationPath exists
192+
try {
193+
if (config.AdoFields.TryGetValue("System.IterationPath", out var iterationPathString)) {
194+
_ = await witClient.GetClassificationNodeAsync(config.Project, TreeStructureGroup.Areas, iterationPathString);
195+
}
196+
} catch (VssUnauthorizedException e) {
197+
return OneFuzzResultVoid.Error(ErrorCode.ADO_VALIDATION_INVALID_PAT, new string[] {
198+
$"Failed to connect to {config.BaseUrl} using the provided token",
199+
$"Exception: {e}"
200+
});
201+
} catch (VssAuthenticationException e) {
202+
return OneFuzzResultVoid.Error(ErrorCode.ADO_VALIDATION_INVALID_PAT, new string[] {
203+
$"Failed to connect to {config.BaseUrl} using the provided token",
204+
$"Exception: {e}"
205+
});
206+
} catch (VssServiceException e) {
207+
return OneFuzzResultVoid.Error(ErrorCode.ADO_VALIDATION_UNEXPECTED_ERROR, new string[] {
208+
"IterationPath error",
209+
$"Exception: {e}",
210+
});
211+
} catch (Exception e) {
212+
return OneFuzzResultVoid.Error(ErrorCode.ADO_VALIDATION_UNEXPECTED_ERROR, new string[] {
213+
"Generic IterationPath error",
214+
$"Exception: {e}",
215+
});
216+
}
217+
218+
165219
return OneFuzzResultVoid.Ok;
166220
}
167221

0 commit comments

Comments
 (0)