Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(Telemetry): Ensure telemetry only matches js stacktrace paths #9447

Merged
merged 1 commit into from May 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/utils/telemetry/resolve-error-location.js
Expand Up @@ -8,7 +8,7 @@ const resolveErrorLocation = (exceptionTokens) => {
const splittedStack = exceptionTokens.stack.split(/[\r\n]+/);
if (splittedStack.length === 1 && exceptionTokens.code) return '<not available>';

const stacktraceLineRegex = /(?:\s*at.*\((.*)\).?|\s*at\s(.*))/;
const stacktraceLineRegex = /(?:\s*at.*\((.*:\d+:\d+)\).?|\s*at\s(.*:\d+:\d+))/;
const stacktracePaths = [];
for (const line of splittedStack) {
const match = line.match(stacktraceLineRegex) || [];
Expand Down
8 changes: 8 additions & 0 deletions test/unit/lib/utils/telemetry/resolve-error-location.test.js
Expand Up @@ -28,6 +28,14 @@ describe('test/unit/lib/utils/resolve-error-location.test.js', () => {
expect(result).to.equal('<not reflected in stack>');
});

it('should not capture non-stacktrace paths', () => {
const err = new Error('test');
err.stack =
'Could not find a version that satisfies the requirement flask (from versions: none) No matching distribution found for flask.';
const result = resolveErrorLocation(tokenizeException(err));
expect(result).to.equal('<not reflected in stack>');
});

if (process.platform !== 'win32') {
it('should correctly handle paths not enclosed in parentheses', () => {
const err = new Error('test');
Expand Down