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

Error on every Parse.Query.find call from the cloud #705

Closed
astanton opened this issue Feb 27, 2016 · 10 comments
Closed

Error on every Parse.Query.find call from the cloud #705

astanton opened this issue Feb 27, 2016 · 10 comments

Comments

@astanton
Copy link

On my startup of my app I am hitting 2 separate cloud calls. Both of the functions return errors, and I've narrowed it down to the query.find() in my cloud code for both methods.

When I get back to the iOS client, I'm getting a Parse error code 141.

But when I'm in the error callback on the server side of things, the object that is returned in there is

{ 
  code: undefined,
  message: unauthorized
}

A little bit more information, as I just added the VERBOSE=1 environment variable. On the calls that are erroring, I get the following message:

error: ParseError { code: 141, message: undefined }

And another thing, I am making calls on the client to the database with PFObject.saveInBackground calls, as well as getting with the PFQuery.getFirstObjectInBackgroundWithBlock calls, so that seems to be working. It's only when trying to do it from the cloud code that appears to be not working.

So I'm wondering if I just completely botched something when setting this up possibly since it's saying I'm unauthorized to query, even though the parse server is running.

My DB is hosted on mongoLab and I have been able to hit it via the CURL methods so the URL is correct.

Any ideas

@jiawenzhang
Copy link

did you set useMasterKey: true ?

@astanton
Copy link
Author

@jiawenzhang I'm not sure where you are referring to setting that. I don't believe I have set anything with that flag.

I'm not sure where to set it either based on the migration guide. It says to pass it as an option into each Parse.Query, so I put it in the object passed into Parse.Query.find() but that did not work.

Previously I was not using the Parse.Cloud.UserMasterKey() function either, but this code was working great on Parse.com hosted server.

@astanton astanton changed the title Error on every Parse.Query.find call Error on every Parse.Query.find call from the cloud Feb 27, 2016
@jiawenzhang
Copy link

check this #650

you need to use it like this

query.find({ useMasterKey: true }).then(...

obj.save(null, { useMasterKey: true }).then(...

@astanton
Copy link
Author

Thanks I figured it out and it had to do with me passing in the clientKey to the config. Thanks though!

@msniff16
Copy link

msniff16 commented Apr 6, 2016

@astanton and @jiawenzhang I'm having this exact issue as well, getting a 141 response when attempting to run query.find() [even with usemasteyKey: true]. @astanton where did you add the clientKey to the config? I thought parse-server advised us to not do this...

@astanton
Copy link
Author

astanton commented Apr 6, 2016

@msniff16 I don't remember exactly the issue since it has been so long, but I believe my solution was to remove the clientKey from the config. I initially had it in there, then when I removed it, everything was working.

@msniff16
Copy link

Hmm, cannot get it to work even without the config. @astanton which version of the parse-server and parse-php sdk were you running?

@Jerland2
Copy link

Jerland2 commented Apr 27, 2016

Also wondering how one has gotten this to work. Does anyone know where I could find a fully working query function with parse-server? I am not sure if the syntax is EXACTLY the same as Parse.com or if there have been any changes. From looking through semi relevant threads I have come to the realization that I need to add query.find({ useMasterKey: true }).then( into the query, is this true?

Edit: I have tried tons of different variations of cloud code queries and ALL of them have responded with the 141 error, I have however successfully called the "hello" function that comes standard. Does anyone have any insight?

@TheRyanHickman
Copy link

@Jerland2 I am still experiencing the same issue. Any guidance would be very helpful.

@Jerland2
Copy link

Jerland2 commented Jun 6, 2016

@TheRyanHickerman

Here is a sample query that works with my Data structure

` saveObject.equalTo("objectId", request.params.objectId);
saveObject.first({
useMasterKey: true,
success: function (Objects) {

}
})
`

Notice the useMasterKey & query.first those were the keys to getting mine to work.

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

5 participants