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

Nested arrays as paramaters to cloud function are serialized incorrectly #2204

Closed
mykelp opened this issue Jul 5, 2016 · 4 comments
Closed

Comments

@mykelp
Copy link

mykelp commented Jul 5, 2016

Issue Description

When sending up parameters for a cloud function, one of my parameters is an array with nested arrays. After version 2.2.11, the nested arrays are being converted into objects.

Steps to reproduce

Send up a request to a cloud function with a parameter as an array with nested arrays.

Expected Results

{ 
  "param": [
    [“equalTo", "seller", { "className": "Organization", "objectId": "rWYBWWgE1b"}],
    ["equalTo", "status", 1],
    ["notEqualTo", "buyer", { "className": "Organization", "objectId": "rWYBWWgE1b" }],
    ["include", "buyer"],
    ["ascending", "buyer.canonicalName"],
    ["skip", 0],
    ["limit", 100]
    ]
}

Actual Outcome

{ 
  "param": [
   { '0': 'equalTo’, ’1’: 'seller','2': { className: 'Organization', objectId: 'rWYBWWgE1b' } },
   { '0': 'equalTo', '1': 'status', '2': 1 },
   { '0': 'notEqualTo', '1': 'buyer', '2': { className: 'Organization', objectId: 'rWYBWWgE1b' } },
   { '0': 'include', '1': 'buyer' },
   { '0': 'ascending', '1': 'buyer.canonicalName' },
   { '0': 'skip', '1': 0 },
   { '0': 'limit', '1': 100 }
   ]
}
@drew-gross
Copy link
Contributor

To help us debug this, can you include the exact request and response in Parse Server, as well as your cloud code? (you can see this in the logs using VERBOSE=1 environment variable)

@dbarabander
Copy link

Hi @drew-gross

I work with @mykelp. I don't get a response as it causes our server to crash. Here is the request:

  verbose: POST /parse/functions/customer { host: 'localhost:3004',
  connection: 'keep-alive',
  'content-length': '546',
  origin: 'http://localhost:3004',
  'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36',
  'content-type': 'text/plain',
  accept: '*/*',
  referer: 'http://localhost:3004/customers-filter?selected=all',
  'accept-encoding': 'gzip, deflate',
  'accept-language': 'en-US,en;q=0.8',
  cookie: 'olfsk=olfsk39934271695225076; hblid=bp4otfnOCMwH6zKA3m39N77zCW0NEQLa; loggedIn=s%3Atrue.DmIvZZE3pg4zmgR5NlKLPOXUCXjQOENpHsqui43ZweM' } {
  "query": [
    [
      "equalTo",
      "seller",
      {
        "className": "Organization",
        "objectId": "qhlLQxW3iY"
      }
    ],
    [
      "equalTo",
      "status",
      1
    ],
    [
      "notEqualTo",
      "buyer",
      {
        "className": "Organization",
        "objectId": "qhlLQxW3iY"
      }
    ],
    [
      "include",
      "buyer"
    ],
    [
      "ascending",
      "buyer.canonicalName"
    ],
    [
      "skip",
      0
    ],
    [
      "limit",
      100
    ]
  ],
  "sellerId": "qhlLQxW3iY"
}

Here is what the query parameter from the request logs on the server

[ { '0': 'equalTo',
    '1': 'seller',
    '2': { className: 'Organization', objectId: 'qhlLQxW3iY' } },
  { '0': 'equalTo', '1': 'status', '2': 1 },
  { '0': 'notEqualTo',
    '1': 'buyer',
    '2': { className: 'Organization', objectId: 'qhlLQxW3iY' } },
  { '0': 'include', '1': 'buyer' },
  { '0': 'ascending', '1': 'buyer.canonicalName' },
  { '0': 'skip', '1': 0 },
  { '0': 'limit', '1': 100 } ]

@dbarabander
Copy link

dbarabander commented Jul 13, 2016

The goal of the code is to reconstruct a query object on the server

@dtsymbal
Copy link

bug is still actual for parse server 2.2.16

cloud function:
Parse.Cloud.define('test', function(request, response) { console.log(request.params); response.success(request.params); });

request:
curl "http://$host/parse/functions/test" -H 'Content-Type: application/json;charset=UTF-8' -H "X-Parse-Application-Id: $appId" --data-binary '{"shouldBeArray": [["a", "b"]]}'
response:
{"result":{"shouldBeArray":[{"0":"a","1":"b"}]}}

flovilmart added a commit that referenced this issue Jul 16, 2016
drew-gross pushed a commit that referenced this issue Jul 19, 2016
…ons (#2297)

* fix for #2294

* fail tests

* Makes sure dates are compatible with Parse.com CloudCode #2214

* Adds regression tests for #2204
rsouzas pushed a commit to back4app/parse-server that referenced this issue Mar 15, 2017
…ons (parse-community#2297)

* fix for parse-community#2294

* fail tests

* Makes sure dates are compatible with Parse.com CloudCode parse-community#2214

* Adds regression tests for parse-community#2204
rsouzas pushed a commit to back4app/parse-server that referenced this issue Mar 16, 2017
…ons (parse-community#2297)

* fix for parse-community#2294

* fail tests

* Makes sure dates are compatible with Parse.com CloudCode parse-community#2214

* Adds regression tests for parse-community#2204
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