Skip to content

Commit 64e387a

Browse files
authored
Improvements to error masking (#4264)
1 parent a497345 commit 64e387a

File tree

5 files changed

+12
-12
lines changed

5 files changed

+12
-12
lines changed

src/commands/createFunctionApp/FunctionAppCreateStep.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { type NameValuePair, type Site, type SiteConfig, type WebSiteManagementC
77
import { BlobServiceClient } from '@azure/storage-blob';
88
import { ParsedSite, WebsiteOS, type CustomLocation, type IAppServiceWizardContext } from '@microsoft/vscode-azext-azureappservice';
99
import { LocationListStep } from '@microsoft/vscode-azext-azureutils';
10-
import { AzureWizardExecuteStep, parseError, randomUtils } from '@microsoft/vscode-azext-utils';
10+
import { AzureWizardExecuteStep, maskUserInfo, parseError, randomUtils } from '@microsoft/vscode-azext-utils';
1111
import { type AppResource } from '@microsoft/vscode-azext-utils/hostapi';
1212
import { type Progress } from 'vscode';
1313
import { FuncVersion, getMajorVersion } from '../../FuncVersion';
@@ -53,7 +53,7 @@ export class FunctionAppCreateStep extends AzureWizardExecuteStep<IFunctionAppWi
5353
await enableFileLogging(context, site);
5454
} catch (error) {
5555
// optional part of creating function app, so not worth blocking on error
56-
context.telemetry.properties.fileLoggingError = parseError(error).message;
56+
context.telemetry.properties.fileLoggingError = maskUserInfo(parseError(error).message, []);
5757
}
5858
}
5959

src/commands/createFunctionApp/stacks/getStackPicks.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import { type ServiceClient } from '@azure/core-client';
77
import { createPipelineRequest } from '@azure/core-rest-pipeline';
88
import { createGenericClient, LocationListStep, type AzExtPipelineResponse } from '@microsoft/vscode-azext-azureutils';
9-
import { openUrl, parseError, type AgentQuickPickItem, type IAzureQuickPickItem } from '@microsoft/vscode-azext-utils';
9+
import { maskUserInfo, openUrl, parseError, type AgentQuickPickItem, type IAzureQuickPickItem } from '@microsoft/vscode-azext-utils';
1010
import { funcVersionLink } from '../../../FuncVersion';
1111
import { hiddenStacksSetting, noRuntimeStacksAvailableLabel } from '../../../constants';
1212
import { previewDescription } from '../../../constants-nls';
@@ -166,7 +166,7 @@ async function getStacks(context: IFunctionAppWizardContext & { _stacks?: Functi
166166
// Some environments (like Azure Germany/Mooncake) don't support the stacks ARM API yet
167167
// And since the stacks don't change _that_ often, we'll just use a backup hard-coded value
168168
stacksArmResponse = <StacksArmResponse>JSON.parse(backupStacks);
169-
context.telemetry.properties.getStacksError = parseError(error).message;
169+
context.telemetry.properties.getStacksError = maskUserInfo(parseError(error).message, []);
170170
}
171171

172172
context._stacks = stacksArmResponse.value.map(d => d.properties);

src/debug/validatePreDebug.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*--------------------------------------------------------------------------------------------*/
55

66
import { BlobServiceClient } from '@azure/storage-blob';
7-
import { AzExtFsExtra, parseError, type IActionContext } from "@microsoft/vscode-azext-utils";
7+
import { AzExtFsExtra, maskUserInfo, parseError, type IActionContext } from "@microsoft/vscode-azext-utils";
88
import * as path from 'path';
99
import * as semver from 'semver';
1010
import * as vscode from 'vscode';
@@ -90,7 +90,7 @@ export async function preDebugValidate(actionContext: IActionContext, debugConfi
9090
} else {
9191
// Don't block debugging for "unexpected" errors. The func cli might still work
9292
shouldContinue = true;
93-
context.telemetry.properties.preDebugValidateError = pe.message;
93+
context.telemetry.properties.preDebugValidateError = maskUserInfo(pe.message, []);
9494
}
9595
}
9696

src/funcCoreTools/validateFuncCoreToolsIsLatest.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55

6-
import { callWithTelemetryAndErrorHandling, DialogResponses, parseError, type IActionContext } from '@microsoft/vscode-azext-utils';
6+
import { callWithTelemetryAndErrorHandling, DialogResponses, maskUserInfo, parseError, type IActionContext } from '@microsoft/vscode-azext-utils';
77
import * as semver from 'semver';
88
import type * as vscode from 'vscode';
99
import { PackageManager } from '../constants';
@@ -120,7 +120,7 @@ async function getNewestFunctionRuntimeVersion(packageManager: PackageManager |
120120
return (await getNpmDistTag(context, versionFromSetting)).value;
121121
}
122122
} catch (error) {
123-
context.telemetry.properties.latestRuntimeError = parseError(error).message;
123+
context.telemetry.properties.latestRuntimeError = maskUserInfo(parseError(error).message, []);
124124
}
125125

126126
return undefined;

src/templates/CentralTemplateProvider.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55

6-
import { parseError, type IActionContext } from '@microsoft/vscode-azext-utils';
6+
import { maskUserInfo, parseError, type IActionContext } from '@microsoft/vscode-azext-utils';
77
import { Disposable, workspace, type ConfigurationChangeEvent } from 'vscode';
88
import { FuncVersion } from '../FuncVersion';
99
import { ProjectLanguage, TemplateFilter, projectTemplateKeySetting } from '../constants';
@@ -237,7 +237,7 @@ export class CentralTemplateProvider implements Disposable {
237237
// This error should be the most actionable to the user, so save it and throw later if cache/backup doesn't work
238238
latestErrorMessage = localize('latestTemplatesError', 'Failed to get latest templates: {0}', errorMessage);
239239
ext.outputChannel.appendLog(latestErrorMessage);
240-
context.telemetry.properties.latestTemplatesError = errorMessage;
240+
context.telemetry.properties.latestTemplatesError = maskUserInfo(errorMessage, []);
241241
}
242242

243243
// 3. Use the cached templates, even if they don't match latestTemplateVersion
@@ -293,7 +293,7 @@ export class CentralTemplateProvider implements Disposable {
293293
} catch (error) {
294294
const errorMessage: string = parseError(error).message;
295295
ext.outputChannel.appendLog(localize('cachedTemplatesError', 'Failed to get cached templates: {0}', errorMessage));
296-
context.telemetry.properties.cachedTemplatesError = errorMessage;
296+
context.telemetry.properties.cachedTemplatesError = maskUserInfo(errorMessage, []);
297297
}
298298
}
299299

@@ -313,7 +313,7 @@ export class CentralTemplateProvider implements Disposable {
313313
} catch (error) {
314314
const errorMessage: string = parseError(error).message;
315315
ext.outputChannel.appendLog(localize('backupTemplatesError', 'Failed to get backup templates: {0}', errorMessage));
316-
context.telemetry.properties.backupTemplatesError = errorMessage;
316+
context.telemetry.properties.backupTemplatesError = maskUserInfo(errorMessage, []);
317317
}
318318
}
319319

0 commit comments

Comments
 (0)