Getting errors on meteor hosting while on localhost everything is fine


#1

Yesterday I deployed my project’s demo on meteor.com free hosting and getting such errors:

Not permitted. Untrusted code may only update documents by ID.

On localhost everything works fine.
Any ideas what happens?

UPDATE

Error from meteor log which I’m getting on startup (run on server):

[Thu Apr 02 2015 10:58:10 GMT+0000 (UTC)] INFO Error in parting personal clients CSV: MongoError: Mod on _id not allowed
[Thu Apr 02 2015 10:58:10 GMT+0000 (UTC)] INFO { [MongoError: Mod on _id not allowed] stack: [Getter] }

See more in discussion below.


#2

This error means, you can only update a document (via the browser) by id only. If you need some other functionality, try to use a method.

Not sure, how it worked in the client.


#3

See here for more info: How to remove doc that don't _id field?


#4

Hmm, I’m using AutoForm to create new document/form and still getting this error (operation is not update but insert!).

Also I’m getting interesting effect. I see new entry for 1sec and then it disappears with MongoError: Mod on _id not allowed [409] error.
So it should be something on server, isn’t it?

One more thing is that all update operations works well.


#5

It’s very strange.

I just did meteor reset on local machine and here is log from console:

=> Started proxy.                             
=> Started MongoDB.                           
I20150402-13:27:18.503(3)? Creating users     
I20150402-13:27:18.504(3)? Kadira: completed instrumenting the app
I20150402-13:27:18.790(3)? Kadira: successfully authenticated
I20150402-13:27:18.973(3)? Users created
I20150402-13:27:20.808(3)? Done persons import
I20150402-13:27:21.181(3)? Done companies import
I20150402-13:27:21.473(3)? Suppliers import DONE!
I20150402-13:27:21.571(3)? Orders import DONE!

Then i did meteor deploy myproject_new (completely new URL), and here is what meteor log myproject_new.meteor.com shows:

[Thu Apr 02 2015 10:28:50 GMT+0000 (UTC)] NOTICE Starting application on port 27850
[Thu Apr 02 2015 10:28:50 GMT+0000 (UTC)] INFO STATUS null -> starting
[Thu Apr 02 2015 10:28:50 GMT+0000 (UTC)] INFO STATUS starting -> running
[Thu Apr 02 2015 10:28:57 GMT+0000 (UTC)] INFO Creating users
[Thu Apr 02 2015 10:28:57 GMT+0000 (UTC)] INFO Kadira: completed instrumenting the app
[Thu Apr 02 2015 10:28:57 GMT+0000 (UTC)] INFO Kadira: successfully authenticated
[Thu Apr 02 2015 10:28:57 GMT+0000 (UTC)] INFO Users created
[Thu Apr 02 2015 10:28:57 GMT+0000 (UTC)] INFO Error in parting personal clients CSV: MongoError: Mod on _id not allowed
[Thu Apr 02 2015 10:28:57 GMT+0000 (UTC)] INFO Error in parsing companies CSV: MongoError: Mod on _id not allowed
[Thu Apr 02 2015 10:28:57 GMT+0000 (UTC)] INFO Error in parsing CSV: MongoError: Mod on _id not allowed
[Thu Apr 02 2015 10:28:57 GMT+0000 (UTC)] INFO Error in parsing ORDERS CSV: Error: Client is required

Here part of code run on startup:

@utils =
  parseCSV: Meteor.wrapAsync Meteor.npmRequire 'csv-parse'

@importCompanies = (text) ->
  try
    output = utils.parseCSV text
    for row in output
      phones = []
      phones.push row[8] if row[8]
      phones.push row[9] if row[9]
      address = "#{row[7]}, #{row[5]} #{row[6]}, #{row[4]}"

      c = Clients.insert
        type: 'company'
        company_name: "#{row[0]}, #{row[1]}"
        code: if row[2] then row[2] else 'Unknown'
        vat_code: row[3]
        loyalty_cards: []
        contacts:
          emails: row[10].split(',')
          phones: phones
          postal_code: row[7]
          country: row[6]
          address: address

    console.log "Done companies import"

  catch err
    console.log "Error in parsing companies CSV: #{err}"

P.S. This code is run on server only.


#6

OK. I finally found problem. The problem was with Clients.findAndModify from fongandrew:find-and-modify package which was called on before.insert.

Now the question is why on localhost everything still works fine?