XervoIO / demeteorizer

Converts a Meteor app into a standard Node.js application.
http://npm.im/demeteorizer
MIT License
703 stars 59 forks source link

Error: key emails.address must not contain '.' #265

Open prashanthmadi opened 7 years ago

prashanthmadi commented 7 years ago

I was trying to run a demeteorized app but it fails with below error. Could you help me debug this issue

I understand that mongo is not allowing .(period) symbol in keys. I couldn't find where i have included it in my meteor code

tried demeteorized -d option but that did not help either.

C:\Workspace\nodejs\koufa.demeteorized\bundle\programs\server>npm start

meteor-dev-bundle@0.0.0 start C:\Workspace\nodejs\koufa.demeteorized\bundle\programs\server node ../../main

Note: you are using a pure-JavaScript implementation of bcrypt. While this implementation will work correctly, it is known to be approximately three times slower than the native implementation. In order to use the native implementation instead, run

meteor npm install --save bcrypt

in the root directory of your application.

C:\Workspace\nodejs\koufa\.demeteorized\bundle\programs\server\node_modules\fibers\future.js:313
                                                throw(ex);
                                                ^
Error: key emails.address must not contain '.'
    at Object.wait (C:\Workspace\nodejs\koufa\.demeteorized\bundle\programs\server\node_modules\fibers\future.js:449:15)
    at MongoConnection._ensureIndex (packages/mongo/mongo_driver.js:828:10)
    at Mongo.Collection._ensureIndex (packages/mongo/collection.js:685:20)
    at setupUsersCollection (packages/accounts-base/accounts_server.js:1492:9)
    at new AccountsServer (packages/accounts-base/accounts_server.js:51:5)
    at meteorInstall.node_modules.meteor.accounts-base.server_main.js (packages/accounts-base/server_main.js:9:12)
    at fileEvaluate (packages\modules-runtime.js:181:9)
    at require (packages\modules-runtime.js:106:16)
    at C:\Workspace\nodejs\koufa\.demeteorized\bundle\programs\server\packages\accounts-base.js:1972:15
    at C:\Workspace\nodejs\koufa\.demeteorized\bundle\programs\server\packages\accounts-base.js:1983:3
    - - - - -
    at Error (native)
    at serializeInto (C:\Workspace\nodejs\koufa\.demeteorized\bundle\programs\server\npm\node_modules\meteor\npm-mongo\node_modules\bson\lib\bson\parser\serializer.js:743:19)
    at serializeObject (C:\Workspace\nodejs\koufa\.demeteorized\bundle\programs\server\npm\node_modules\meteor\npm-mongo\node_modules\bson\lib\bson\parser\serializer.js:300:18)
    at serializeInto (C:\Workspace\nodejs\koufa\.demeteorized\bundle\programs\server\npm\node_modules\meteor\npm-mongo\node_modules\bson\lib\bson\parser\serializer.js:766:17)
    at serializeObject (C:\Workspace\nodejs\koufa\.demeteorized\bundle\programs\server\npm\node_modules\meteor\npm-mongo\node_modules\bson\lib\bson\parser\serializer.js:300:18)
    at serializeInto (C:\Workspace\nodejs\koufa\.demeteorized\bundle\programs\server\npm\node_modules\meteor\npm-mongo\node_modules\bson\lib\bson\parser\serializer.js:608:17)
    at serializeObject (C:\Workspace\nodejs\koufa\.demeteorized\bundle\programs\server\npm\node_modules\meteor\npm-mongo\node_modules\bson\lib\bson\parser\serializer.js:300:18)
    at serializeInto (C:\Workspace\nodejs\koufa\.demeteorized\bundle\programs\server\npm\node_modules\meteor\npm-mongo\node_modules\bson\lib\bson\parser\serializer.js:766:17)
    at BSON.serialize (C:\Workspace\nodejs\koufa\.demeteorized\bundle\programs\server\npm\node_modules\meteor\npm-mongo\node_modules\bson\lib\bson\bson.js:49:27)
    at Query.toBin (C:\Workspace\nodejs\koufa\.demeteorized\bundle\programs\server\npm\node_modules\meteor\npm-mongo\node_modules\mongodb-core\lib\connection\commands.js:143:25)
fiveisprime commented 7 years ago

What version of Meteor are you on and did you recently update?

fiveisprime commented 7 years ago

I guessing that somewhere in your code you are attempting to find or update a user object from MongoDB like this

Meteor.users.find( { emails.address: 'user@example.com' })

The MongoDB drive requires the nested values to be in quotes to access

Meteor.users.find( { 'emails.address': 'user@example.com' })

// or

Meteor.users.find( { emails: { address: 'user@example.com' } })

Check through your code and report back. :)

prashanthmadi commented 7 years ago

Thanks for helping with this @fiveisprime

I haven't found any address/email in my code but have seen some in .meteor / .demeteor folder

COuld be that one of the module i'm using might have it...

image

mattdell commented 7 years ago

I'm having the same problem. Were you able to fix this @prashanthmadi ?

prashanthmadi commented 7 years ago

are you using documentdb ? we tried with mlab and it worked :)

mattdell commented 7 years ago

@prashanthmadi yep! That is exactly how I just spent the last 3 hours. ๐Ÿ˜„

prashanthmadi commented 7 years ago

@mattdell is your issue resolved ?

mattdell commented 7 years ago

Yep ๐Ÿ‘

prashanthmadi commented 7 years ago

Do you have simple steps to repro this issue. I will work with documentdb team to fix it.

As you can see below that insert with โ€œ.โ€ In key doesnโ€™t work even with mongo shell. You can try it on your local environment

db.test.insert({"a.1":1})

2017-02-23T14:01:07.655-0800 E QUERY    [thread1] Error: can't have . in field names [a.1] : 
DBCollection.prototype._validateForStorage@src/mongo/shell/collection.js:181:1
Bulk/this.insert@src/mongo/shell/bulk_api.js:646:9
DBCollection.prototype.insert@src/mongo/shell/collection.js:271:13
@(shell):1:1 

No idea on why it's working using mlab..

haha454 commented 7 years ago

@fiveisprime I am having the same issue when I am deploying a Meteor app using Azure MongoDB. I guess this is the line which raises the exception.

https://github.com/meteor/meteor/blob/master/packages/accounts-base/accounts_server.js#L1492

As can be seen, it does have quotes when accessing nested keys, but I still don't understand why it is working when I using a mlab.com sandbox MongoDB while it throws such exception when using Azure MongoDB.

@prashanthmadi You can only query a nested document in this way, but to insert document, I guess we cannot do so. I tested on both Azure MongoDB and mlab MongoDB, and db.test.insert({"a.1":1}) is not allowed on both.

https://docs.mongodb.com/manual/tutorial/insert-documents/ https://docs.mongodb.com/manual/tutorial/query-embedded-documents/

prashanthmadi commented 7 years ago

Hi @weitony111, I have discussed on this issue with DocumentDB Team today. Can you send an email to askdocdbmongoapi@microsoft.com .

Disclaimer: I work at Microsoft Azure

fiveisprime commented 7 years ago

I didn't realize that, in the original issue, you were using DocumentDB over MongoDB! It makes some kind of sense now. :) I'm guessing that DocumentDB doesn't support this part of the API yet.

@weitony111 when you send that email, please copy maherna@microsoft.com as well so I can track this for future DocumentDB use cases.

@prashanthmadi ๐Ÿ‘‹ from Redmond.

haha454 commented 7 years ago

@fiveisprime Oh, yeah, thanks for reminding. I actually chose MongoDB as my NoSQL API in Azure NoSQL (DocumentDB). I overlooked it since I thought it will work exactly the same way as MongoDB, but now it seems not. I'll send an email tomorrow since it is too late in Singapore now...

fiveisprime commented 7 years ago

From the DocumentDB team

Looks like the problem is with ensureIndex since unique index is not supported yet (itโ€™s coming this week) but will only enabled for new accounts at first... until we enable migration from old accounts.

kulttuuri commented 7 years ago

Any news on this one @prashanthmadi @fiveisprime? Doesn't seem to be enabled yet for new accounts. Running to the same problem with fresh azure cosmosDB database. Tried fresh database and imported database. Works fine on other DB services.

garychapman commented 6 years ago

FWIW it's mid-October and I'm seeing the same results on Azure Cosmos DB