Nested arrays as paramaters to cloud function are serialized incorrectly
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 }
]
}
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)
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 } ]
The goal of the code is to reconstruct a query object on the server
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"}]}}