parse-server: Cloud code not working after migration

After migration we thought we had everything up and running but then realized that we were receiving erroneous responses from the server (AWS). We are sending latitude and longitude as params when we call PFCloud in iOS, like so:

NSDictionary *params = @{
                       @"latitude" : [NSNumber numberWithDouble:(double)self.location.coordinate.latitude],
                       @"longitude" : [NSNumber numberWithDouble:(double)self.location.coordinate.longitude]
                             };
[PFCloud callFunctionInBackground:@"myQuery" withParameters:params block:^(NSArray *response, NSError *error) {
...
}];

and then in cloud code we access it like so:

var latitude = request.params.latitude;
var longitude = request.params.longitude;

This worked perfectly on parse.com but since the move to AWS and parse server, it doesn’t work. I wrapped each request in parseFloat() thinking it might fix it but it didn’t.

It works again if I hardcode a latitude and longitude in the cloud code. So what is the issue with sending this a params to the cloud code with the hosted parse server?

Expected Results

The script should return a query limited by latitude and longitude.

Actual Outcome

The script disregards lat and long and returns everything

Environment Setup

  • Server
    • parse-server version: latest as of last month
    • Localhost or remote server? (AWS, Heroku, Azure, Digital Ocean, etc): AWS
  • Database
    • MongoDB version: latest as of last month
    • Localhost or remote server? (AWS, mLab, ObjectRocket, Digital Ocean, etc): mLab

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 24 (13 by maintainers)

Most upvoted comments

@ArchonLight the best thing to do to help track down this issue is to post your latest curl statement, verbose server log (including the request to cloud code, the REST request that is then made, and the response), and source code for the simplest cloud code function that reproduces the bug. This is because there is already a lot of info and changes in this ticket so want to focus on a single issue.

You can also open a PR with a unit test that reproduces the bug.

I strongly recommend you use a fixed version of parse-server and not the version “latest” because you may get changes you don’t expect. Also, a specific version is required to debug any issue here. Suggest going with 2.2.17 or whatever previous version works well for you.

The if statement stuff looks like a separate JavaScript code issue due to falsey values. If the values are falsey on request.params when they shouldn’t be, then that could be a parse-server issue and it can be addressed here.