Skip to content

[Bug]: ObjectId in meta transformed to empty object #258

@alice-telescoop

Description

@alice-telescoop

🔎 Search Terms

ObjectId,mongo

The problem

When using winston-mongodband logging mongo documents, the _id (and I think any property typed ObjectId) is transformed to {}

I encounter this when logging authenticated user through express-winston.

I use mongodb driver version 4.3.0

What version of Winston presents the issue?

v5.1.1

What version of Node are you using?

v18.17.1

If this worked in a previous version of Winston, which was it?

No response

Minimum Working Example

No response

Additional information

While debugging the problem on my side, I figured that it is the helper cloneMeta that causes the issue : the test node instanceof ObjectID returns false whereas I guess it should return true

function cloneMeta(node, optParents) {
  if (!((node !== null && typeof node === 'object') || typeof node === 'function')
      || (node instanceof ObjectID) || (node instanceof Buffer)) {
    return node;
    }
    // ...
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions