fast-redact icon indicating copy to clipboard operation
fast-redact copied to clipboard

Error is thrown for wildcard paths against object with nested null values

Open kostya-luxuryescape opened this issue 3 years ago • 1 comments

Hi,

Thanks a lot for the great lib.

I just wanted to raise this bug. An error is thrown in this edge case:

    const redact = fastRedact({
      paths: ['*.*.x'],
      serialize: false,
      censor: "[REDACTED]",
    });

    expect(redact({a: {b: null}})).toEqual({a: {b: null}});

Cannot use 'in' operator to search for 'x' in null TypeError: Cannot use 'in' operator to search for 'x' in null at specialSet (/workspace/lib-logger/node_modules/fast-redact/lib/modifiers.js:120:53) at nestedRedact (/workspace/lib-logger/node_modules/fast-redact/lib/modifiers.js:73:7)

kostya-luxuryescape avatar Feb 23 '22 06:02 kostya-luxuryescape

I have a very simple PR to fix it ready to go: https://github.com/davidmarkclements/fast-redact/pull/47

kostya-luxuryescape avatar Feb 23 '22 06:02 kostya-luxuryescape