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

Bug: masking logic throws exception for Errors with read only properties #217

Closed
rothfels opened this issue Feb 22, 2023 · 3 comments
Closed
Labels
bug Something isn't working

Comments

@rothfels
Copy link

rothfels commented Feb 22, 2023

Describe the bug

When I log.error any Error that has read only properties, tslog throws an exception:

.../node_modules/tslog/dist/cjs/BaseLogger.js:179
                                    o[prop] = keys.includes(this.settings?.maskValuesOfKeysCaseInsensitive !== true ? prop : prop.toLowerCase())
                                            ^

TypeError: Cannot assign to read only property '$response' of object 'ValidationException: ...'
    .../node_modules/tslog/dist/cjs/BaseLogger.js:179:45

To Reproduce
Steps to reproduce the behavior:

var tslog = require('tslog')
var logger = new tslog.Logger()

function createReadonlyError(message, property) {
  const error = new Error(message);
  Object.defineProperty(error, 'property', {
    value: property,
    writable: false,
    enumerable: true,
    configurable: false
  });
  return error;
}

var e = createReadonlyError('message', 'property')

logger.error(e)

Expected behavior

Don't throw exceptions when logging errors (or any object with readonly props for that matter)

Additional context

Using tslog@4.7.4

Node.js Version
18.14.0

OS incl. Version
macOS 12.5

@rothfels rothfels added the bug Something isn't working label Feb 22, 2023
@terehov
Copy link
Contributor

terehov commented Feb 22, 2023

Thank you. I'll fix it soon.

@terehov
Copy link
Contributor

terehov commented Feb 23, 2023

V4.7.5 is out.

@rothfels
Copy link
Author

Thank you @terehov ! Appreciate the fast turnaround.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants