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

Client side idStringify error (objects other than ObjectID) also with _id="" after core packages upgrade #9060

Closed
jankapunkt opened this issue Sep 6, 2017 · 1 comment · Fixed by #9062
Assignees
Labels
confirmed We want to fix or implement it Project:Minimongo Type:Bug

Comments

@jankapunkt
Copy link
Contributor

The version of Meteor showing the problem.
Meteor version: 1.5.1

Packages updated:

accounts-base          upgraded from 1.3.1 to 1.3.2
babel-compiler         upgraded from 6.19.4 to 6.20.0
boilerplate-generator  upgraded from 1.1.1 to 1.2.0
ddp-client             upgraded from 2.0.0 to 2.1.0
ejson                  upgraded from 1.0.13 to 1.0.14
minifier-js            upgraded from 2.1.1 to 2.1.2
minimongo              upgraded from 1.2.1 to 1.3.0
modules                upgraded from 0.9.4 to 0.10.0
mongo                  upgraded from 1.1.22 to 1.2.0
mongo-dev-server       added, version 1.0.1
promise                upgraded from 0.8.9 to 0.9.0
webapp                 upgraded from 1.3.17 to 1.3.18

The last version of Meteor where the problem did not occur (if applicable)
Same version before the update.

The operating system you're running Meteor on.
MacOs, but problem also occurs on Ubuntu 16.04.2 LTS Linux local and production.

The expected behavior
Before the update there were no problems with calling collection.findOne("") or collection.findOne({_id:""}). I expect the function findOne to return a falsey value, such as null or undefined.

The actual behavior.
Throws error on collection.findOne({_id:""})

Error: Meteor does not currently support objects other than ObjectID as ids
idStringify — 436bf8d602463537fc560f5794e92e560aa45dc0.js:56258
get — 436bf8d602463537fc560f5794e92e560aa45dc0.js:56013
e — 436bf8d602463537fc560f5794e92e560aa45dc0.js:57512
e — 436bf8d602463537fc560f5794e92e560aa45dc0.js:57443:156
e — 436bf8d602463537fc560f5794e92e560aa45dc0.js:57495
e — 436bf8d602463537fc560f5794e92e560aa45dc0.js:57393
e — 436bf8d602463537fc560f5794e92e560aa45dc0.js:45:14769
e — 436bf8d602463537fc560f5794e92e560aa45dc0.js:57658:119
findOne — 436bf8d602463537fc560f5794e92e560aa45dc0.js:62014

Is this behavior to be expected now with the updated packages?

I checked the mongo 2.6 merge and it seems, that it introduces new _id handling?

A simple reproduction!
Create a new Meteor project with the above package versions and call findOne({_id:""}) on a arbitrary client side collection.

@klaussner klaussner added Type:Bug confirmed We want to fix or implement it Project:Minimongo labels Sep 6, 2017
@klaussner
Copy link
Contributor

klaussner commented Sep 6, 2017

Here is a reproduction repo: https://github.com/klaussner/meteor-issues/tree/9060. It looks like this bug was introduced in #8893, specifically by this commit. The following line assigns the selector object instead of the _id to this._selectorId if the _id in the selector object is an empty string:

this._selectorId = selector._id || selector;

Unminified stack trace:

Uncaught Error: Meteor does not currently support objects other than ObjectID as ids
    at _IdMap.MongoID.idStringify [as _idStringify] (mongo-id.js?hash=345d169d517353f8146292b4abd24061721f8b26:104)
    at _IdMap.get (id-map.js?hash=c7aea8dfa2bf46ff2ae0aa6c6cf09e36abc61d07:46)
    at Cursor._getRawObjects (cursor.js:377)
    at Cursor.forEach (cursor.js:103)
    at Cursor.fetch (cursor.js:68)
    at LocalCollection.findOne (local_collection.js:86)
    at Mongo.Collection.findOne (collection.js:334)
    at index.js (index.js:4)
    at fileEvaluate (modules-runtime.js?hash=8587d188e038b75ecd27ed2469a52b269e38fb62:343)
    at require (modules-runtime.js?hash=8587d188e038b75ecd27ed2469a52b269e38fb62:238)

@klaussner klaussner self-assigned this Sep 6, 2017
dr-dimitru added a commit to veliovgroup/meteor-autoform-file that referenced this issue Sep 10, 2017
 - Hot fix for #32, see #33 and
[meteor/#9060](meteor/meteor#9060), thanks to
@jankapunkt
 - Dependencies update
 - Overall fixes
 - Compatibility with `[email protected]`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
confirmed We want to fix or implement it Project:Minimongo Type:Bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants