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

Exception when a modifier with undefined values is used #398

Open
xolott opened this issue Sep 28, 2023 · 2 comments · May be fixed by #399
Open

Exception when a modifier with undefined values is used #398

xolott opened this issue Sep 28, 2023 · 2 comments · May be fixed by #399

Comments

@xolott
Copy link

xolott commented Sep 28, 2023

When this modifier is used, redis-oplog throws an exception:

const modifer = {
    $addToSet: undefined
};

Collection.update(selector, modifier);

Exception:

Exception in setInterval callback: TypeError: Cannot convert undefined or null to object
    at Function.keys (<anonymous>)
    at packages/cultofcoders:redis-oplog/lib/utils/getFields.js:12:20
    at Array.forEach (<anonymous>)
    at getFields (packages/cultofcoders:redis-oplog/lib/utils/getFields.js:10:29)
    at ns.Collection.update (packages/cultofcoders:redis-oplog/lib/mongo/Mutator.js:198:32)
    at ns.Collection.update (packages/cultofcoders:redis-oplog/lib/mongo/extendMongoCollection.js:40:35)

I think the issue is in this line:

if (op[0] == '$') {

Something like this should work.

    const isNil = (value) => value === null || value === undefined;
    Object.entries(mutator).forEach(function ([op, params]) {
        if (op[0] == '$' && !isNil(params)) {

A modifier with a value undefined is valid for the mongo driver. It just ignores it.

@github-actions
Copy link

Thank you for submitting this issue!

We, the Members of Meteor Community Packages take every issue seriously.
Our goal is to provide long-term lifecycles for packages and keep up
with the newest changes in Meteor and the overall NodeJs/JavaScript ecosystem.

However, we contribute to these packages mostly in our free time.
Therefore, we can't guarantee you issues to be solved within certain time.

If you think this issue is trivial to solve, don't hesitate to submit
a pull request, too! We will accompany you in the process with reviews and hints
on how to get development set up.

Please also consider sponsoring the maintainers of the package.
If you don't know who is currently maintaining this package, just leave a comment
and we'll let you know

@xolott xolott linked a pull request Sep 28, 2023 that will close this issue
@xolott
Copy link
Author

xolott commented Sep 28, 2023

I created the PR #399 with what I think would fix the issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant