@@ -91,21 +91,26 @@ private static bool IsTransient(Exception e) {
9191
9292 private static async Async . Task < OneFuzzResultVoid > ValidatePath ( string project , string path , TreeStructureGroup structureGroup , WorkItemTrackingHttpClient client ) {
9393 var pathParts = path . Split ( '\\ ' ) ;
94- var i = pathParts [ 0 ] == project ? 1 : 0 ;
94+ if ( pathParts [ 0 ] != project ) {
95+ return OneFuzzResultVoid . Error ( ErrorCode . ADO_VALIDATION_INVALID_PATH , new string [ ] {
96+ $ "Path \" { path } \" is invalid. It must start with the project name, \" { project } \" .",
97+ $ "Example: \" { project } \\ { path } \" .",
98+ } ) ;
99+ }
95100
96- var current = await client . GetClassificationNodeAsync ( project , structureGroup , depth : pathParts . Length - i ) ;
101+ var current = await client . GetClassificationNodeAsync ( project , structureGroup , depth : pathParts . Length - 1 ) ;
97102 if ( current == null ) {
98103 return OneFuzzResultVoid . Error ( ErrorCode . ADO_VALIDATION_INVALID_PATH , new string [ ] {
99- $ "Path { path } is invalid. { project } is not a valid project",
104+ $ "Path \" { path } \" is invalid. \" { project } \" is not a valid project. ",
100105 } ) ;
101106 }
102107
103- for ( ; i < pathParts . Length ; i ++ ) {
104- var child = current . Children ? . FirstOrDefault ( x => x . Name == pathParts [ i ] ) ;
108+ foreach ( var part in pathParts . Skip ( 1 ) ) {
109+ var child = current . Children ? . FirstOrDefault ( x => x . Name == part ) ;
105110 if ( child == null ) {
106111 return OneFuzzResultVoid . Error ( ErrorCode . ADO_VALIDATION_INVALID_PATH , new string [ ] {
107- $ "Path { path } is invalid. { pathParts [ i ] } is not a valid child of { current . Name } ",
108- $ "Valid children of { current . Name } are: [{ string . Join ( ',' , current . Children ? . Select ( x => x . Name ) ?? new List < string > ( ) ) } ]",
112+ $ "Path \" { path } \" is invalid. \" { part } \" is not a valid child of \" { current . Name } \" . ",
113+ $ "Valid children of \" { current . Name } \" are: [{ string . Join ( ',' , current . Children ? . Select ( x => $ " \" { x . Name } \" " ) ?? new List < string > ( ) ) } ]. ",
109114 } ) ;
110115 }
111116
0 commit comments