Skip to content

Commit 5f964db

Browse files
authored
Fix #19726 (#19755)
* Fix #19726 Add type check to avoid errors when the thrown exception is an object * Format the code
1 parent e496052 commit 5f964db

20 files changed

+92
-74
lines changed

Tasks/AzureCLIV1/azureclitask.ts

+8-5
Original file line numberDiff line numberDiff line change
@@ -108,16 +108,19 @@ export class azureclitask {
108108

109109
//set the task result to either succeeded or failed based on error was thrown or not
110110
if (toolExecutionError) {
111-
let message = tl.loc("ScriptFailed", toolExecutionError);
111+
let message = tl.loc('ScriptFailed', toolExecutionError);
112112

113-
const expiredSecretErrorCode = "AADSTS7000222";
114-
let serviceEndpointSecretIsExpired = toolExecutionError.indexOf(expiredSecretErrorCode) >= 0;
115-
if (serviceEndpointSecretIsExpired) {
113+
if (typeof toolExecutionError === 'string') {
114+
const expiredSecretErrorCode = 'AADSTS7000222';
115+
let serviceEndpointSecretIsExpired = toolExecutionError.indexOf(expiredSecretErrorCode) >= 0;
116+
117+
if (serviceEndpointSecretIsExpired) {
116118
const organizationURL = tl.getVariable('System.CollectionUri');
117119
const projectName = tl.getVariable('System.TeamProject');
118120
const serviceConnectionLink = encodeURI(`${organizationURL}${projectName}/_settings/adminservices?resourceId=${connectedService}`);
119-
121+
120122
message = tl.loc('ExpiredServicePrincipalMessageWithLink', serviceConnectionLink);
123+
}
121124
}
122125

123126
tl.setResult(tl.TaskResult.Failed, message);

Tasks/AzureCLIV1/task.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"version": {
2121
"Major": 1,
2222
"Minor": 238,
23-
"Patch": 0
23+
"Patch": 2
2424
},
2525
"minimumAgentVersion": "2.0.0",
2626
"instanceNameFormat": "Azure CLI $(scriptPath)",

Tasks/AzureCLIV1/task.loc.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"version": {
2121
"Major": 1,
2222
"Minor": 238,
23-
"Patch": 0
23+
"Patch": 2
2424
},
2525
"minimumAgentVersion": "2.0.0",
2626
"instanceNameFormat": "ms-resource:loc.instanceNameFormat",

Tasks/AzureCLIV2/azureclitask.ts

+12-9
Original file line numberDiff line numberDiff line change
@@ -95,19 +95,22 @@ export class azureclitask {
9595
if(toolExecutionError === FAIL_ON_STDERR) {
9696
tl.setResult(tl.TaskResult.Failed, tl.loc("ScriptFailedStdErr"));
9797
} else if (toolExecutionError) {
98-
let message = tl.loc("ScriptFailed", toolExecutionError);
98+
let message = tl.loc('ScriptFailed', toolExecutionError);
9999

100-
const expiredSecretErrorCode = "AADSTS7000222";
100+
if (typeof toolExecutionError === 'string') {
101+
const expiredSecretErrorCode = 'AADSTS7000222';
101102
let serviceEndpointSecretIsExpired = toolExecutionError.indexOf(expiredSecretErrorCode) >= 0;
103+
102104
if (serviceEndpointSecretIsExpired) {
103-
const organizationURL = tl.getVariable('System.CollectionUri');
104-
const projectName = tl.getVariable('System.TeamProject');
105-
const serviceConnectionLink = encodeURI(`${organizationURL}${projectName}/_settings/adminservices?resourceId=${connectedService}`);
106-
107-
message = tl.loc('ExpiredServicePrincipalMessageWithLink', serviceConnectionLink);
105+
const organizationURL = tl.getVariable('System.CollectionUri');
106+
const projectName = tl.getVariable('System.TeamProject');
107+
const serviceConnectionLink = encodeURI(`${organizationURL}${projectName}/_settings/adminservices?resourceId=${connectedService}`);
108+
109+
message = tl.loc('ExpiredServicePrincipalMessageWithLink', serviceConnectionLink);
108110
}
109-
110-
tl.setResult(tl.TaskResult.Failed, message);
111+
}
112+
113+
tl.setResult(tl.TaskResult.Failed, message);
111114
} else if (exitCode != 0){
112115
tl.setResult(tl.TaskResult.Failed, tl.loc("ScriptFailedWithExitCode", exitCode));
113116
}

Tasks/AzureCLIV2/task.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"version": {
2121
"Major": 2,
2222
"Minor": 238,
23-
"Patch": 0
23+
"Patch": 2
2424
},
2525
"minimumAgentVersion": "2.0.0",
2626
"instanceNameFormat": "Azure CLI $(scriptPath)",

Tasks/AzureCLIV2/task.loc.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"version": {
2121
"Major": 2,
2222
"Minor": 238,
23-
"Patch": 0
23+
"Patch": 2
2424
},
2525
"minimumAgentVersion": "2.0.0",
2626
"instanceNameFormat": "ms-resource:loc.instanceNameFormat",

_generated/AzureCLIV1.versionmap.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
Default|1.238.0
2-
Node20_229_2|1.238.1
1+
Default|1.238.2
2+
Node20_229_2|1.238.3

_generated/AzureCLIV1/azureclitask.ts

+8-5
Original file line numberDiff line numberDiff line change
@@ -108,16 +108,19 @@ export class azureclitask {
108108

109109
//set the task result to either succeeded or failed based on error was thrown or not
110110
if (toolExecutionError) {
111-
let message = tl.loc("ScriptFailed", toolExecutionError);
111+
let message = tl.loc('ScriptFailed', toolExecutionError);
112112

113-
const expiredSecretErrorCode = "AADSTS7000222";
114-
let serviceEndpointSecretIsExpired = toolExecutionError.indexOf(expiredSecretErrorCode) >= 0;
115-
if (serviceEndpointSecretIsExpired) {
113+
if (typeof toolExecutionError === 'string') {
114+
const expiredSecretErrorCode = 'AADSTS7000222';
115+
let serviceEndpointSecretIsExpired = toolExecutionError.indexOf(expiredSecretErrorCode) >= 0;
116+
117+
if (serviceEndpointSecretIsExpired) {
116118
const organizationURL = tl.getVariable('System.CollectionUri');
117119
const projectName = tl.getVariable('System.TeamProject');
118120
const serviceConnectionLink = encodeURI(`${organizationURL}${projectName}/_settings/adminservices?resourceId=${connectedService}`);
119-
121+
120122
message = tl.loc('ExpiredServicePrincipalMessageWithLink', serviceConnectionLink);
123+
}
121124
}
122125

123126
tl.setResult(tl.TaskResult.Failed, message);

_generated/AzureCLIV1/task.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"version": {
2121
"Major": 1,
2222
"Minor": 238,
23-
"Patch": 0
23+
"Patch": 2
2424
},
2525
"minimumAgentVersion": "2.0.0",
2626
"instanceNameFormat": "Azure CLI $(scriptPath)",
@@ -161,7 +161,7 @@
161161
"ExpiredServicePrincipalMessageWithLink": "Secret expired, update service connection at\u00A0%s See\u00A0https://aka.ms/azdo-rm-workload-identity-conversion to learn more about conversion to secret-less service connections."
162162
},
163163
"_buildConfigMapping": {
164-
"Default": "1.238.0",
165-
"Node20_229_2": "1.238.1"
164+
"Default": "1.238.2",
165+
"Node20_229_2": "1.238.3"
166166
}
167167
}

_generated/AzureCLIV1/task.loc.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"version": {
2121
"Major": 1,
2222
"Minor": 238,
23-
"Patch": 0
23+
"Patch": 2
2424
},
2525
"minimumAgentVersion": "2.0.0",
2626
"instanceNameFormat": "ms-resource:loc.instanceNameFormat",
@@ -161,7 +161,7 @@
161161
"ExpiredServicePrincipalMessageWithLink": "ms-resource:loc.messages.ExpiredServicePrincipalMessageWithLink"
162162
},
163163
"_buildConfigMapping": {
164-
"Default": "1.238.0",
165-
"Node20_229_2": "1.238.1"
164+
"Default": "1.238.2",
165+
"Node20_229_2": "1.238.3"
166166
}
167167
}

_generated/AzureCLIV1_Node20/azureclitask.ts

+8-5
Original file line numberDiff line numberDiff line change
@@ -108,16 +108,19 @@ export class azureclitask {
108108

109109
//set the task result to either succeeded or failed based on error was thrown or not
110110
if (toolExecutionError) {
111-
let message = tl.loc("ScriptFailed", toolExecutionError);
111+
let message = tl.loc('ScriptFailed', toolExecutionError);
112112

113-
const expiredSecretErrorCode = "AADSTS7000222";
114-
let serviceEndpointSecretIsExpired = toolExecutionError.indexOf(expiredSecretErrorCode) >= 0;
115-
if (serviceEndpointSecretIsExpired) {
113+
if (typeof toolExecutionError === 'string') {
114+
const expiredSecretErrorCode = 'AADSTS7000222';
115+
let serviceEndpointSecretIsExpired = toolExecutionError.indexOf(expiredSecretErrorCode) >= 0;
116+
117+
if (serviceEndpointSecretIsExpired) {
116118
const organizationURL = tl.getVariable('System.CollectionUri');
117119
const projectName = tl.getVariable('System.TeamProject');
118120
const serviceConnectionLink = encodeURI(`${organizationURL}${projectName}/_settings/adminservices?resourceId=${connectedService}`);
119-
121+
120122
message = tl.loc('ExpiredServicePrincipalMessageWithLink', serviceConnectionLink);
123+
}
121124
}
122125

123126
tl.setResult(tl.TaskResult.Failed, message);

_generated/AzureCLIV1_Node20/task.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"version": {
2121
"Major": 1,
2222
"Minor": 238,
23-
"Patch": 1
23+
"Patch": 3
2424
},
2525
"minimumAgentVersion": "2.0.0",
2626
"instanceNameFormat": "Azure CLI $(scriptPath)",
@@ -165,7 +165,7 @@
165165
"ExpiredServicePrincipalMessageWithLink": "Secret expired, update service connection at\u00A0%s See\u00A0https://aka.ms/azdo-rm-workload-identity-conversion to learn more about conversion to secret-less service connections."
166166
},
167167
"_buildConfigMapping": {
168-
"Default": "1.238.0",
169-
"Node20_229_2": "1.238.1"
168+
"Default": "1.238.2",
169+
"Node20_229_2": "1.238.3"
170170
}
171171
}

_generated/AzureCLIV1_Node20/task.loc.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"version": {
2121
"Major": 1,
2222
"Minor": 238,
23-
"Patch": 1
23+
"Patch": 3
2424
},
2525
"minimumAgentVersion": "2.0.0",
2626
"instanceNameFormat": "ms-resource:loc.instanceNameFormat",
@@ -165,7 +165,7 @@
165165
"ExpiredServicePrincipalMessageWithLink": "ms-resource:loc.messages.ExpiredServicePrincipalMessageWithLink"
166166
},
167167
"_buildConfigMapping": {
168-
"Default": "1.238.0",
169-
"Node20_229_2": "1.238.1"
168+
"Default": "1.238.2",
169+
"Node20_229_2": "1.238.3"
170170
}
171171
}

_generated/AzureCLIV2.versionmap.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
Default|2.238.0
2-
Node20_229_2|2.238.1
1+
Default|2.238.2
2+
Node20_229_2|2.238.3

_generated/AzureCLIV2/azureclitask.ts

+12-9
Original file line numberDiff line numberDiff line change
@@ -95,19 +95,22 @@ export class azureclitask {
9595
if(toolExecutionError === FAIL_ON_STDERR) {
9696
tl.setResult(tl.TaskResult.Failed, tl.loc("ScriptFailedStdErr"));
9797
} else if (toolExecutionError) {
98-
let message = tl.loc("ScriptFailed", toolExecutionError);
98+
let message = tl.loc('ScriptFailed', toolExecutionError);
9999

100-
const expiredSecretErrorCode = "AADSTS7000222";
100+
if (typeof toolExecutionError === 'string') {
101+
const expiredSecretErrorCode = 'AADSTS7000222';
101102
let serviceEndpointSecretIsExpired = toolExecutionError.indexOf(expiredSecretErrorCode) >= 0;
103+
102104
if (serviceEndpointSecretIsExpired) {
103-
const organizationURL = tl.getVariable('System.CollectionUri');
104-
const projectName = tl.getVariable('System.TeamProject');
105-
const serviceConnectionLink = encodeURI(`${organizationURL}${projectName}/_settings/adminservices?resourceId=${connectedService}`);
106-
107-
message = tl.loc('ExpiredServicePrincipalMessageWithLink', serviceConnectionLink);
105+
const organizationURL = tl.getVariable('System.CollectionUri');
106+
const projectName = tl.getVariable('System.TeamProject');
107+
const serviceConnectionLink = encodeURI(`${organizationURL}${projectName}/_settings/adminservices?resourceId=${connectedService}`);
108+
109+
message = tl.loc('ExpiredServicePrincipalMessageWithLink', serviceConnectionLink);
108110
}
109-
110-
tl.setResult(tl.TaskResult.Failed, message);
111+
}
112+
113+
tl.setResult(tl.TaskResult.Failed, message);
111114
} else if (exitCode != 0){
112115
tl.setResult(tl.TaskResult.Failed, tl.loc("ScriptFailedWithExitCode", exitCode));
113116
}

_generated/AzureCLIV2/task.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"version": {
2121
"Major": 2,
2222
"Minor": 238,
23-
"Patch": 0
23+
"Patch": 2
2424
},
2525
"minimumAgentVersion": "2.0.0",
2626
"instanceNameFormat": "Azure CLI $(scriptPath)",
@@ -204,7 +204,7 @@
204204
"ExpiredServicePrincipalMessageWithLink": "Secret expired, update service connection at\u00A0%s See\u00A0https://aka.ms/azdo-rm-workload-identity-conversion to learn more about conversion to secret-less service connections."
205205
},
206206
"_buildConfigMapping": {
207-
"Default": "2.238.0",
208-
"Node20_229_2": "2.238.1"
207+
"Default": "2.238.2",
208+
"Node20_229_2": "2.238.3"
209209
}
210210
}

_generated/AzureCLIV2/task.loc.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"version": {
2121
"Major": 2,
2222
"Minor": 238,
23-
"Patch": 0
23+
"Patch": 2
2424
},
2525
"minimumAgentVersion": "2.0.0",
2626
"instanceNameFormat": "ms-resource:loc.instanceNameFormat",
@@ -204,7 +204,7 @@
204204
"ExpiredServicePrincipalMessageWithLink": "ms-resource:loc.messages.ExpiredServicePrincipalMessageWithLink"
205205
},
206206
"_buildConfigMapping": {
207-
"Default": "2.238.0",
208-
"Node20_229_2": "2.238.1"
207+
"Default": "2.238.2",
208+
"Node20_229_2": "2.238.3"
209209
}
210210
}

_generated/AzureCLIV2_Node20/azureclitask.ts

+12-9
Original file line numberDiff line numberDiff line change
@@ -95,19 +95,22 @@ export class azureclitask {
9595
if(toolExecutionError === FAIL_ON_STDERR) {
9696
tl.setResult(tl.TaskResult.Failed, tl.loc("ScriptFailedStdErr"));
9797
} else if (toolExecutionError) {
98-
let message = tl.loc("ScriptFailed", toolExecutionError);
98+
let message = tl.loc('ScriptFailed', toolExecutionError);
9999

100-
const expiredSecretErrorCode = "AADSTS7000222";
100+
if (typeof toolExecutionError === 'string') {
101+
const expiredSecretErrorCode = 'AADSTS7000222';
101102
let serviceEndpointSecretIsExpired = toolExecutionError.indexOf(expiredSecretErrorCode) >= 0;
103+
102104
if (serviceEndpointSecretIsExpired) {
103-
const organizationURL = tl.getVariable('System.CollectionUri');
104-
const projectName = tl.getVariable('System.TeamProject');
105-
const serviceConnectionLink = encodeURI(`${organizationURL}${projectName}/_settings/adminservices?resourceId=${connectedService}`);
106-
107-
message = tl.loc('ExpiredServicePrincipalMessageWithLink', serviceConnectionLink);
105+
const organizationURL = tl.getVariable('System.CollectionUri');
106+
const projectName = tl.getVariable('System.TeamProject');
107+
const serviceConnectionLink = encodeURI(`${organizationURL}${projectName}/_settings/adminservices?resourceId=${connectedService}`);
108+
109+
message = tl.loc('ExpiredServicePrincipalMessageWithLink', serviceConnectionLink);
108110
}
109-
110-
tl.setResult(tl.TaskResult.Failed, message);
111+
}
112+
113+
tl.setResult(tl.TaskResult.Failed, message);
111114
} else if (exitCode != 0){
112115
tl.setResult(tl.TaskResult.Failed, tl.loc("ScriptFailedWithExitCode", exitCode));
113116
}

_generated/AzureCLIV2_Node20/task.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"version": {
2121
"Major": 2,
2222
"Minor": 238,
23-
"Patch": 1
23+
"Patch": 3
2424
},
2525
"minimumAgentVersion": "2.0.0",
2626
"instanceNameFormat": "Azure CLI $(scriptPath)",
@@ -208,7 +208,7 @@
208208
"ExpiredServicePrincipalMessageWithLink": "Secret expired, update service connection at\u00A0%s See\u00A0https://aka.ms/azdo-rm-workload-identity-conversion to learn more about conversion to secret-less service connections."
209209
},
210210
"_buildConfigMapping": {
211-
"Default": "2.238.0",
212-
"Node20_229_2": "2.238.1"
211+
"Default": "2.238.2",
212+
"Node20_229_2": "2.238.3"
213213
}
214214
}

_generated/AzureCLIV2_Node20/task.loc.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"version": {
2121
"Major": 2,
2222
"Minor": 238,
23-
"Patch": 1
23+
"Patch": 3
2424
},
2525
"minimumAgentVersion": "2.0.0",
2626
"instanceNameFormat": "ms-resource:loc.instanceNameFormat",
@@ -208,7 +208,7 @@
208208
"ExpiredServicePrincipalMessageWithLink": "ms-resource:loc.messages.ExpiredServicePrincipalMessageWithLink"
209209
},
210210
"_buildConfigMapping": {
211-
"Default": "2.238.0",
212-
"Node20_229_2": "2.238.1"
211+
"Default": "2.238.2",
212+
"Node20_229_2": "2.238.3"
213213
}
214214
}

0 commit comments

Comments
 (0)