Skip to content

Commit

Permalink
remove stacks in error stack
Browse files Browse the repository at this point in the history
  • Loading branch information
rtpascual committed Feb 18, 2025
1 parent 2a08ebf commit 38e3dd3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -124,4 +124,17 @@ void describe('serializable error', () => {
`${expectedFilePath} is not found in ${serializableError.stack}`
);
});

void test('that error stack does not contain stacks', () => {
const error = new Error('test error');
error.stack =
'Stack with id amplify-test-stack-sandbox-12345abcde does not exist';

Check warning on line 131 in packages/platform-core/src/telemetry-data/serializable_error.test.ts

View workflow job for this annotation

GitHub Actions / lint

You have a misspelled word: 12345abcde on String
const serializableError = new SerializableError(error);
assert.ok(
serializableError.stack.includes(
'Stack with id <escaped stack> does not exist'
),
`Stack is not removed in ${serializableError.stack}`
);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ export class SerializableError {
? this.sanitize(error.code as string)
: error.name;
this.message = this.anonymizePaths(this.sanitize(error.message));
this.stack = this.anonymizePaths(error.stack ?? '');
this.stack = error.stack
? this.anonymizePaths(this.sanitize(error.stack))
: '';
}

private anonymizePaths = (str: string): string => {
Expand Down

0 comments on commit 38e3dd3

Please sign in to comment.