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

Cannot read property '$set' of undefined #474

Open
knoxgon opened this issue Dec 20, 2022 · 2 comments
Open

Cannot read property '$set' of undefined #474

knoxgon opened this issue Dec 20, 2022 · 2 comments

Comments

@knoxgon
Copy link

knoxgon commented Dec 20, 2022

I'm trying to execute existing operations upon migrating from 1.13.1 to 3.4 and certain update operations fail to execute and throws the same error.

Everything up to version 3.2 seems to work fine. From 3.3 and upwards (3.4 the latest as of today) have this problem.

This issue seems to coming from aldeed:collection2-core package where the selector mapping is performed against ObjectID, _id or string.

E.g., it totally ignores the logical operators such as $and and $or. So the docId is always null within the named cases.

The package aldeed:collection2-core/collection2.js has not been updated for some years. Although, since it worked with the earlier simpl-schema versions, I'm not entirely sure if the problem actually coming from that package. I guess the way data is passed to that object from simpl-schema introduces anomalies.

Filename: aldeed:collection2-core/collection2.js

image

This is the operation where I perform the update

MyTestCollection.update(
    { "$and": [{"$or": [{"$and": [{"currlaunch": "dataset"}] }] }, {"groupid": {"$ne": "98n2z62tgb519"} }] },
    { "$push": { "posit": {.....objects....}, "emps": { "$each": ['a', 'b', 'c']} }, "$set": { "iter.datecol": Date.now() } },
    { multi: true, upsert: false }
)

The same operation works on all versions except version 3.3 and 3.4.

And for the named reason, the obj property becomes undefined.

Filename: simpl-schema/src/validation/requiredValidator.ts
image

@github-actions
Copy link

Thank you for submitting an issue!

If this is a bug report, please be sure to include, at minimum, example code showing a small schema and any necessary calls with all their arguments, which will reproduce the issue. Even better, you can link to a saved online code editor example, where anyone can immediately run the code and see the issue.

If you are requesting a feature, include a code example of how you imagine it working if it were implemented.

If you need to edit your issue description, click the [...] and choose Edit.

Be patient. This is a free and freely licensed package that I maintain in my spare time. You may get a response in a day, but it could also take a month. If you benefit from this package and would like to see more of my time devoted to it, you can help by sponsoring.

@aldeed
Copy link
Collaborator

aldeed commented Feb 25, 2023

Does it matter what schema is attached? Can you post an example schema that will reproduce 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

No branches or pull requests

2 participants