From 44b81f68dd1d37d780a26e8c5e20cad24e76fcdb Mon Sep 17 00:00:00 2001 From: Daniel Gasienica Date: Wed, 7 Mar 2018 10:57:04 -0500 Subject: [PATCH] Remove privacy redaction from `Errors.toLogFormat` --- js/modules/types/errors.js | 4 +--- test/modules/types/errors_test.js | 37 ++++++++++++++++++------------- 2 files changed, 22 insertions(+), 19 deletions(-) diff --git a/js/modules/types/errors.js b/js/modules/types/errors.js index 52252fb1f..eba76af47 100644 --- a/js/modules/types/errors.js +++ b/js/modules/types/errors.js @@ -1,9 +1,7 @@ const ensureError = require('ensure-error'); -const Privacy = require('../privacy'); - // toLogFormat :: Error -> String exports.toLogFormat = (error) => { const normalizedError = ensureError(error); - return Privacy.redactAll(normalizedError.stack); + return normalizedError.stack; }; diff --git a/test/modules/types/errors_test.js b/test/modules/types/errors_test.js index 77dfc82f8..945ce68ee 100644 --- a/test/modules/types/errors_test.js +++ b/test/modules/types/errors_test.js @@ -9,31 +9,36 @@ const APP_ROOT_PATH = Path.join(__dirname, '..', '..', '..'); describe('Errors', () => { describe('toLogFormat', () => { - it('should redact sensitive paths in stack trace', () => { + it('should convert non-errors to errors', () => { try { - throw new Error('boom'); - } catch (error) { - assert.include( - error.stack, - APP_ROOT_PATH, - 'Unformatted stack has sensitive paths' - ); + // eslint-disable-next-line no-throw-literal + throw 'boom'; + } catch (nonError) { + assert.typeOf(nonError, 'string'); + assert.isUndefined(nonError.stack); - const formattedStack = Errors.toLogFormat(error); - assert.notInclude( - formattedStack, - APP_ROOT_PATH, - 'Formatted stack does not have sensitive paths' - ); + const formattedStack = Errors.toLogFormat(nonError); assert.include( formattedStack, - '[REDACTED]', - 'Formatted stack has redactions' + APP_ROOT_PATH, + 'Formatted stack has app path' ); return; } + // eslint-disable-next-line no-unreachable assert.fail('Expected error to be thrown.'); }); + + it('should add stack to errors without one', () => { + const error = new Error('boom'); + error.stack = null; + assert.typeOf(error, 'Error'); + assert.isNull(error.stack); + + const formattedStack = Errors.toLogFormat(error); + assert.include(formattedStack, ''); + assert.include(formattedStack, APP_ROOT_PATH, 'Formatted stack has app path'); + }); }); });