Skip to content

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

Description

@astanton

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

Activity

  1. jiawenzhang commented on Feb 27, 2016

    @jiawenzhang

    did you set useMasterKey: true ?

  2. astanton commented on Feb 27, 2016

    @astanton
    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.

  3. changed the title [-]Error on every Parse.Query.find call[/-] [+]Error on every Parse.Query.find call from the cloud[/+] on Feb 27, 2016
  4. jiawenzhang commented on Feb 27, 2016

    @jiawenzhang

    check this #650

    you need to use it like this

    query.find({ useMasterKey: true }).then(...
    
    obj.save(null, { useMasterKey: true }).then(...
    
  5. astanton commented on Feb 27, 2016

    @astanton
    Author

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

  6. msniff16 commented on Apr 6, 2016

    @msniff16

    @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...

  7. astanton commented on Apr 6, 2016

    @astanton
    Author

    @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.

  8. msniff16 commented on Apr 11, 2016

    @msniff16

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

  9. Jerland2 commented on Apr 27, 2016

    @Jerland2

    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?

  10. TheRyanHickman commented on Jun 6, 2016

    @TheRyanHickman

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

  11. Jerland2 commented on Jun 6, 2016

    @Jerland2

    @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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions