parse-server icon indicating copy to clipboard operation
parse-server copied to clipboard

Crash when trying to included non-includable keys. Parse.com just ignores those keys.

Open lguerra10 opened this issue 10 years ago • 19 comments

nimble parse server, using IOS SDK Parse (1.13.0), ParseUI (1.2.0) with PFQueryTableViewController a simple query to get all records in a Class returns zero objects. This behaviour happens with queries restricting the number of objects. Actually happens with any kind of query.

The query works OK using tableView instead of PFQueryTableViewController. The query using PFQueryTableViewController woks perfectly in the original Parse. the query: query = PFQuery(className: "Request") The table has records

lguerra10 avatar May 14 '16 02:05 lguerra10

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

drew-gross avatar May 14 '16 08:05 drew-gross

Im working to get the logs. Meanwhile I got the following error in X-code

[Error]: can only include pointer fields (Code: 102, Version: 1.13.0) the query includes the following query.orderByDescending("createdAt") query.includeKey("owner") query.includeKey("taggedFriends") query.includeKey("images") query.includeKey("photoEntry")

where images is an array of PFFiles and taggedFriends is an array of PFUsers owner is a PFUser and photoEntry is a PFObject

this query runs without any problem against the Parse database and return the records as expected Im working to get the logs

lguerra10 avatar May 14 '16 18:05 lguerra10

mine is the same error described in this issue: Using includeKey: on array of pointers results in error #1293 the error is in the getObjectInBackground . it has nothing to do with PFQueryTableViewController it happens in regular tableViews. here is my log from nimble. The error is still happening.

verbose : GET /classes/Request { host: 'kliqueshare.api.nimbleparse.com', [2016-05-14T21:03:55.457558146Z] 'user-agent': 'Kollective/1 CFNetwork/758.3.15 Darwin/15.4.0', [2016-05-14T21:03:55.457690719Z] 'content-length': '264', [2016-05-14T21:03:55.457788066Z] accept: '/', [2016-05-14T21:03:55.457810149Z] 'accept-encoding': 'gzip, deflate', [2016-05-14T21:03:55.457938552Z] 'accept-language': 'en-us', [2016-05-14T21:03:55.45807278Z] 'content-type': 'application/json; charset=utf-8', [2016-05-14T21:03:55.45811034Z] 'x-forwarded-for': '187.216.107.215', [2016-05-14T21:03:55.458253027Z] 'x-forwarded-port': '443', [2016-05-14T21:03:55.458368834Z] 'x-forwarded-proto': 'https', [2016-05-14T21:03:55.458408368Z] 'x-parse-app-build-version': '1', [2016-05-14T21:03:55.45853241Z] 'x-parse-app-display-version': '1.0', [2016-05-14T21:03:55.458674422Z] 'x-parse-application-id': 'iPZmJrnoFVdVDwAcq2JEQ4szjSpS7rPYyNQcB804', [2016-05-14T21:03:55.458692575Z] 'x-parse-client-key': 'ER570jkwVbh5QE0OFcOx9LyGsp3DgC3Jw2gNzFV7', [2016-05-14T21:03:55.458814796Z] 'x-parse-client-version': 'i1.13.0', [2016-05-14T21:03:55.458912989Z] 'x-parse-installation-id': 'cf815f5c-e556-4ff4-a703-32472e5617b8', [2016-05-14T21:03:55.458933724Z] 'x-parse-os-version': '9.3 (15E65)', [2016-05-14T21:03:55.459146087Z] 'x-parse-session-token': 'r:488b1948ff90066407ed0b7412f1f85f', [2016-05-14T21:03:55.459257127Z] 'x-request-id': 'aaf23651-85be-4cc6-8f05-0e7101e50992', [2016-05-14T21:03:55.459278661Z] 'x-request-start': '1463259839490' } { [2016-05-14T21:03:55.459422866Z] "include": "images,owner,photoEntry,taggedFriends", [2016-05-14T21:03:55.459530553Z] "order": "-createdAt", [2016-05-14T21:03:55.459551906Z] "where": { [2016-05-14T21:03:55.459666742Z] "$or": [ [2016-05-14T21:03:55.459777601Z] { [2016-05-14T21:03:55.459814567Z] "owner": { [2016-05-14T21:03:55.459919553Z] "__type": "Pointer", [2016-05-14T21:03:55.460037298Z] "className": "_User", [2016-05-14T21:03:55.460060407Z] "objectId": "F8YbdLXxo4" [2016-05-14T21:03:55.460204862Z] } [2016-05-14T21:03:55.460306991Z] }, [2016-05-14T21:03:55.460342057Z] { [2016-05-14T21:03:55.460533192Z] "taggedFriends": { [2016-05-14T21:03:55.46063295Z] "__type": "Pointer", [2016-05-14T21:03:55.460650725Z] "className": "_User", [2016-05-14T21:03:55.460754269Z] "objectId": "F8YbdLXxo4" [2016-05-14T21:03:55.460878882Z] } [2016-05-14T21:03:55.460896688Z] } [2016-05-14T21:03:55.460995039Z] ] [2016-05-14T21:03:55.461115287Z] } [2016-05-14T21:03:55.461137981Z] } [2016-05-14T21:03:55.486935767Z] verbose : error: code=102, message=can only include pointer fields [2016-05-14T21:03:55.487742632Z] GET /classes/Request 400 31.930 ms - 54

if it helps there is only one record to be retrieved and this is the record in the database

{ "description": "Size 4. Need for one weekend at the beach ", "category": "apparel", "searchString": "apparel denim shorts luis guerra", "shippingCost": 0, "_p_owner": "_User$F8YbdLXxo4", "priceForRent": 5, "priceForSale": 0, "searchWords": [ "apparel", "denim", "shorts", "luis", "guerra" ], "mood": "", "color": "", "subCategory": "denim", "dateNeeded": ISODate("2016-05-21T06:00:00.000Z"), "taggedFriends": [ { "__type": "Pointer", "className": "_User", "objectId": "ZoIx1ObV37" } ], "images": [ { "__type": "File", "url": "https://kliqueshare.s3.amazonaws.com/393470260e870e0460288ad2f71dab5b_file.bin", "name": "393470260e870e0460288ad2f71dab5b_file.bin" } ], "rentalOrPurchase": "", "name": "Denim shorts ", "status": "" }

lguerra10 avatar May 14 '16 21:05 lguerra10

Are trying to use includeKey on a non-pointer field. That won't work. Leave out the includeKey.

drew-gross avatar May 15 '16 03:05 drew-gross

Thanks for the hep. I understand the problem, but the suggested solution implies rewriting our code. My only question is: Will this problem be fixed down the road and when (estimate) If the problem will not be fixed or it may take too long (more than a couple of weeks), then I will start rewriting my code now. Can you answer this question? Thanks a lot

luis guerra

On Sat, May 14, 2016 at 9:36 PM, Drew [email protected] wrote:

Are trying to use includeKey on a non-pointer field. That won't work. Leave out the includeKey.

— You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub https://github.com/ParsePlatform/parse-server/issues/1788#issuecomment-219264359

Join me on Vsee video chat. It is free http://vsee.com/u/lpva1m

lguerra10 avatar May 15 '16 03:05 lguerra10

Did this code work when using Parse.com? If so we should fix the bug. That said, it should be fairly easy to fix your code as all you have to do is remove includeKey whenever you are trying to include a non-pointer.

drew-gross avatar May 15 '16 06:05 drew-gross

the code works perfectly in Parse.com.

Any estimate of how long would it take to fix the bug?

We are ready to go the App store and the rewrite affects a good number of screens, but my recommendation to the boss is to start the rewrite now unless you can tell me that the bug fix could take less than 2 weeks?. It will take between 2 weeks and one month to do the rewrite.

thanks

lguerra10 avatar May 15 '16 12:05 lguerra10

We can probably get it fixed this week. Can you also show the contents of your _SCHEMA collection for the class you are querying?

drew-gross avatar May 16 '16 20:05 drew-gross

Nevermind, I think I can fix this without needing that info.

drew-gross avatar May 16 '16 21:05 drew-gross

This is fixed by #1811 and will be in a new release later today.

drew-gross avatar May 16 '16 22:05 drew-gross

Never mind, still investigating.

drew-gross avatar May 16 '16 23:05 drew-gross

@lguerra10 I've investigated this further and haven't actually found a difference between the behaviour in Parse.com and Parse Server. Can you try sending the query you provided with only one include at a time, and tell us which specific key is the one that causes the error? If possible, include a cURL request, and the schema for both your Parse Server app and your Parse.com app.

drew-gross avatar May 16 '16 23:05 drew-gross

I dont understand what you are asking with _SCHEMA. I already included the query and the json of the object that should have been returned. the include.taggedFriends and the include.images generated the error because both are arrays of pointers to objects

thanks for the estimate of the time for the correction of the problem

On Mon, May 16, 2016 at 2:30 PM, Drew [email protected] wrote:

We can probably get it fixed this week. Can you also show the contents of your _SCHEMA collection for the class you are querying?

— You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub https://github.com/ParsePlatform/parse-server/issues/1788#issuecomment-219538062

Join me on Vsee video chat. It is free http://vsee.com/u/lpva1m

lguerra10 avatar May 17 '16 18:05 lguerra10

If you go to the API Console, and put schemas/YOUR_CLASS_NAME as the endpoint, and use master key, you can see the schema for your class. Please post that here for both your Parse.com app and your Parse Server app. Also, we have test cases that pass for using include with arrays or missing keys in Parse Server, and I just tried it on my own Parse Server as well, and it worked.

I understand you've already provided the query, but we also need the state of the database. If you can provide some code I can run that starts from an empty database and demonstrates the error, then I should be able to fix the bug.

drew-gross avatar May 17 '16 18:05 drew-gross

I am facing the same issue here (v.2.2.7). Using the parse-dashboard I can always fetch the object however from the clients it fails for some objects from the same class. I can't figure out what's triggering the problem:

curl -X GET -H "X-Parse-Application-Id: lHC0oT3G1oZRPB2otwYngjMjKnsOVFGfxWw5PrTM" \
-H "X-Parse-Master-Key: 69iG67YzS0FddY17VmX0Jo2DwK6SjJkg0Gfp3lhO" \
-G --data-urlencode "include=items,customer,customer.address,shippingAddress,salesPerson" \
https://4bb2ef61.ngrok.io/parse/classes/Order/3Wca6ieu2b

{"code":102,"error":"can only include pointer fields"}

Log from the server:

verbose: GET /parse/classes/Order/3Wca6ieu2b?include=items%2Ccustomer%2Ccustomer.address%2CshippingAddress%2CsalesPerson { host: '4bb2ef61.ngrok.io',
'user-agent': 'curl/7.43.0',
accept: '*/*',
'x-parse-application-id': 'lHC0oT3G1oZRPB2otwYngjMjKnsOVFGfxWw5PrTM',
'x-parse-master-key': '69iG67YzS0FddY17VmX0Jo2DwK6SjJkg0Gfp3lhO',
'x-forwarded-proto': 'https',
'x-forwarded-for': '177.135.93.250' } {}
verbose: error: code=102, message=can only include pointer fields

The object fetched from the parse dashboard, the problematic field is the array items:

{
    "ACL": {
        "role:XGuL13tmmC_admin": {
            "read": true,
            "write": true
        },
        "FoLQeHLHSp": {
            "read": true,
            "write": true
        }
    },
    "objectId": "0Vi9wUny4g",
    "orderGwId": "ORD-I642V4R5S9NW",
    "createdAt": "2016-03-30T18:36:55.360Z",
    "installmentsWithoutInterest": 1,
    "items": [
        {
            "ACL": {
                "*": {
                    "read": true
                },
                "FoLQeHLHSp": {
                    "write": true
                }
            },
            "objectId": "XcHXTkM62c",
            "createdAt": "2016-03-30T18:36:32.967Z",
            "detail": "Vermelha",
            "price": 100,
            "variant": {
                "objectId": "TliG4d28lL",
                "createdAt": "2016-01-08T20:23:54.109Z",
                "updatedAt": "2016-04-05T17:26:16.725Z",
                "thumbnail": {
                    "__type": "File",
                    "name": "tfss-13a78409-8b20-4cf7-89e6-600ca0e06747-thumbnail_img_20160101_190537.jpg",
                    "url": "http://files.parsetfss.com/8333ecf9-2580-4888-8c4a-9766c1197fea/tfss-13a78409-8b20-4cf7-89e6-600ca0e06747-thumbnail_img_20160101_190537.jpg"
                },
                "image": {
                    "__type": "File",
                    "name": "tfss-01569853-33a3-46dd-b85c-08a5e5a63207-img_20160101_190537.jpg",
                    "url": "http://files.parsetfss.com/8333ecf9-2580-4888-8c4a-9766c1197fea/tfss-01569853-33a3-46dd-b85c-08a5e5a63207-img_20160101_190537.jpg"
                },
                "price": 150,
                "definition1Value": "Vermelha",
                "salePrice": 100,
                "erpId": "007",
                "__type": "Object",
                "className": "Variant"
            },
            "product": "Bola",
            "quantity": 1,
            "updatedAt": "2016-03-30T18:36:32.967Z",
            "__type": "Object",
            "className": "Item"
        }
    ],
    "freightCost": 20,
    "pickUpInStore": true,
    "salesPerson": {
        "ACL": {
            "FoLQeHLHSp": {
                "read": true,
                "write": true
            },
            "*": {
                "read": true
            }
        },
        "objectId": "FoLQeHLHSp",
        "username": "[email protected]",
        "updatedAt": "2016-04-29T20:23:09.530Z",
        "name": "Jean Paulo",
        "jid": "[email protected]",
        "createdAt": "2015-11-30T19:36:40.812Z",
        "disabled": false,
        "retailer": {
            "__type": "Pointer",
            "className": "Retailer",
            "objectId": "XGuL13tmmC"
        },
        "visible": true,
        "lastName": "de Almeida",
        "avatar": {
            "__type": "File",
            "name": "tfss-96557066-eb4b-4b10-99b0-7c92d0ae08df-image1461941244693.jpg",
            "url": "http://files.parsetfss.com/8333ecf9-2580-4888-8c4a-9766c1197fea/tfss-96557066-eb4b-4b10-99b0-7c92d0ae08df-image1461941244693.jpg"
        },
        "email": "[email protected]",
        "confirm": "teste",
        "__type": "Object",
        "className": "_User"
    },
    "retailer": {
        "__type": "Pointer",
        "className": "Retailer",
        "objectId": "XGuL13tmmC"
    },
    "canAcceptBoleto": true,
    "customer": {
        "objectId": "UzdNSBTVaD",
        "retailer": {
            "__type": "Pointer",
            "className": "Retailer",
            "objectId": "6I5ZciIDSp"
        },
        "taxDocumentNumber": "08398351918",
        "birthDate": {
            "__type": "Date",
            "iso": "1992-07-22T03:00:00.000Z"
        },
        "lastName": "Jean Paulo",
        "createdAt": "2016-03-24T12:11:31.668Z",
        "name": "Jean Paulo",
        "phoneNumber": "87398516",
        "updatedAt": "2016-03-24T12:11:31.668Z",
        "canonicalSearch": [
            "jean",
            "paulo",
            "jean",
            "paulo",
            "87398516",
            "08398351918"
        ],
        "phoneAreaCode": "41",
        "__type": "Object",
        "className": "Customer"
    },
    "status": "OPEN",
    "discount": 20,
    "deliveryTime": "10",
    "paymentsURL": [
        {
            "__type": "Pointer",
            "className": "PaymentURL",
            "objectId": "W4SMxBd0Am"
        },
        {
            "__type": "Pointer",
            "className": "PaymentURL",
            "objectId": "JVWvC9q4sH"
        },
        {
            "__type": "Pointer",
            "className": "PaymentURL",
            "objectId": "1YYjgJHBMc"
        }
    ],
    "retailerOrderId": "1092",
    "updatedAt": "2016-05-19T20:59:30.075Z"
}

Now the same query for another object from the same class is OK:

curl -X GET -H "X-Parse-Application-Id: lHC0oT3G1oZRPB2otwYngjMjKnsOVFGfxWw5PrTM" \
-H "X-Parse-Master-Key: 69iG67YzS0FddY17VmX0Jo2DwK6SjJkg0Gfp3lhO" \
-G --data-urlencode "include=items,customer,customer.address,shippingAddress,salesPerson" \
https://4bb2ef61.ngrok.io/parse/classes/Order/0Vi9wUny4g

{
    "ACL": {
        "role:XGuL13tmmC_admin": {
            "read": true,
            "write": true
        },
        "FoLQeHLHSp": {
            "read": true,
            "write": true
        }
    },
    "objectId": "0Vi9wUny4g",
    "orderGwId": "ORD-I642V4R5S9NW",
    "createdAt": "2016-03-30T18:36:55.360Z",
    "installmentsWithoutInterest": 1,
    "items": [
        {
            "ACL": {
                "*": {
                    "read": true
                },
                "FoLQeHLHSp": {
                    "write": true
                }
            },
            "objectId": "XcHXTkM62c",
            "createdAt": "2016-03-30T18:36:32.967Z",
            "detail": "Vermelha",
            "price": 100,
            "variant": {
                "__type": "Pointer",
                "className": "Variant",
                "objectId": "TliG4d28lL"
            },
            "product": "Bola",
            "quantity": 1,
            "updatedAt": "2016-03-30T18:36:32.967Z",
            "__type": "Object",
            "className": "Item"
        }
    ],
    "freightCost": 20,
    "pickUpInStore": true,
    "salesPerson": {
        "ACL": {
            "FoLQeHLHSp": {
                "read": true,
                "write": true
            },
            "*": {
                "read": true
            }
        },
        "objectId": "FoLQeHLHSp",
        "username": "[email protected]",
        "updatedAt": "2016-04-29T20:23:09.530Z",
        "name": "Jean Paulo",
        "jid": "[email protected]",
        "createdAt": "2015-11-30T19:36:40.812Z",
        "disabled": false,
        "retailer": {
            "__type": "Pointer",
            "className": "Retailer",
            "objectId": "XGuL13tmmC"
        },
        "visible": true,
        "lastName": "de Almeida",
        "avatar": {
            "__type": "File",
            "name": "tfss-96557066-eb4b-4b10-99b0-7c92d0ae08df-image1461941244693.jpg",
            "url": "http://files.parsetfss.com/8333ecf9-2580-4888-8c4a-9766c1197fea/tfss-96557066-eb4b-4b10-99b0-7c92d0ae08df-image1461941244693.jpg"
        },
        "email": "[email protected]",
        "confirm": "teste",
        "__type": "Object",
        "className": "_User"
    },
    "retailer": {
        "__type": "Pointer",
        "className": "Retailer",
        "objectId": "XGuL13tmmC"
    },
    "canAcceptBoleto": true,
    "customer": {
        "objectId": "UzdNSBTVaD",
        "retailer": {
            "__type": "Pointer",
            "className": "Retailer",
            "objectId": "6I5ZciIDSp"
        },
        "taxDocumentNumber": "08398351918",
        "birthDate": {
            "__type": "Date",
            "iso": "1992-07-22T03:00:00.000Z"
        },
        "lastName": "Jean Paulo",
        "createdAt": "2016-03-24T12:11:31.668Z",
        "name": "Jean Paulo",
        "phoneNumber": "87398516",
        "updatedAt": "2016-03-24T12:11:31.668Z",
        "canonicalSearch": [
            "jean",
            "paulo",
            "jean",
            "paulo",
            "87398516",
            "08398351918"
        ],
        "phoneAreaCode": "41",
        "__type": "Object",
        "className": "Customer"
    },
    "status": "OPEN",
    "discount": 20,
    "deliveryTime": "10",
    "paymentsURL": [
        {
            "__type": "Pointer",
            "className": "PaymentURL",
            "objectId": "W4SMxBd0Am"
        },
        {
            "__type": "Pointer",
            "className": "PaymentURL",
            "objectId": "JVWvC9q4sH"
        },
        {
            "__type": "Pointer",
            "className": "PaymentURL",
            "objectId": "1YYjgJHBMc"
        }
    ],
    "retailerOrderId": "1092",
    "updatedAt": "2016-05-19T20:59:30.075Z"
}

The object schema:

{
    "className": "Order",
    "fields": {
        "shippingAddress": {
            "type": "Pointer",
            "targetClass": "Address"
        },
        "shippingMethod": {
            "type": "String"
        },
        "freightCost": {
            "type": "Number"
        },
        "retailerOrderId": {
            "type": "String"
        },
        "salesPerson": {
            "type": "Pointer",
            "targetClass": "_User"
        },
        "buyer": {
            "type": "Pointer",
            "targetClass": "_User"
        },
        "deliveryTime": {
            "type": "String"
        },
        "orderGwId": {
            "type": "String"
        },
        "status": {
            "type": "String"
        },
        "items": {
            "type": "Array"
        },
        "interest": {
            "type": "Number"
        },
        "pickUpInStore": {
            "type": "Boolean"
        },
        "orderPayGwId": {
            "type": "String"
        },
        "discount": {
            "type": "Number"
        },
        "installmentsWithInterest": {
            "type": "Number"
        },
        "installmentsWithoutInterest": {
            "type": "Number"
        },
        "paymentsURL": {
            "type": "Array"
        },
        "canAcceptBoleto": {
            "type": "Boolean"
        },
        "retailer": {
            "type": "Pointer",
            "targetClass": "Retailer"
        },
        "customer": {
            "type": "Pointer",
            "targetClass": "Customer"
        },
        "paymentMethod": {
            "type": "String"
        },
        "orderGatewayWebHooks": {
            "type": "Array"
        },
        "paymentInstallmentsCount": {
            "type": "Number"
        },
        "statusChange": {
            "type": "Array"
        },
        "sourceApp": {
            "type": "String"
        },
        "ACL": {
            "type": "ACL"
        },
        "createdAt": {
            "type": "Date"
        },
        "updatedAt": {
            "type": "Date"
        },
        "objectId": {
            "type": "String"
        }
    },
    "classLevelPermissions": {
        "find": {
            "FoLQeHLHSp": true,
            "*": true
        },
        "get": {
            "*": true,
            "FoLQeHLHSp": true
        },
        "create": {
            "*": true,
            "FoLQeHLHSp": true
        },
        "update": {
            "*": true,
            "FoLQeHLHSp": true
        },
        "delete": {},
        "addField": {
            "FoLQeHLHSp": true
        },
        "readUserFields": [],
        "writeUserFields": []
    }
}

flavionegrao avatar May 19 '16 21:05 flavionegrao

As I've mentioned earlier, we have lots of test cases for include. Can you try to come up with a reduced test case? One that includes as few keys as possible, and retrieves as simple an object as possible?

drew-gross avatar May 19 '16 23:05 drew-gross

I have rewritten my code (took me a few days) to avoid arrays of pointers, it is hard for me to reproduce the problem.

I had a case with a Class with 2 arrays one of PFUser and one of PFFile none of the arrays was retrieved. It was a problem or retrieving arrays of pointers.

On Thu, May 19, 2016 at 5:27 PM, Drew [email protected] wrote:

As I've mentioned earlier, we have lots of test cases for include. Can you try to come up with a reduced test case? One that includes as few keys as possible, and retrieves as simple an object as possible?

— You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub https://github.com/ParsePlatform/parse-server/issues/1788#issuecomment-220475616

Join me on Vsee video chat. It is free http://vsee.com/u/lpva1m

lguerra10 avatar May 20 '16 00:05 lguerra10

Hi @drew-gross could you point out where should I include a test case for this issue? I managed to find the problem I believe. The passed object is not a pointer but a populated object when including an Array of pointers for some scenarios:

// RestQuery.js
...
  if (path.length == 0) {
    if (object.__type == 'Pointer') {
      return [object];
    }
    throw new Parse.Error(Parse.Error.INVALID_QUERY, 'can only include pointer fields');
  }

So that changing it apparently fixed to problem:

// RestQuery.js

if (path.length == 0) {
    if (object.__type == 'Pointer') {
      return [object];
    } else if (object.__type === 'Object') {
      return [{
        __type: "Pointer",
        className: object.className,
        objectId: object.objectId,
      }];
    }
    throw new Parse.Error(Parse.Error.INVALID_QUERY, 'can only include pointer fields');
  }

flavionegrao avatar Jun 28 '16 21:06 flavionegrao

This should be fixed by #2263

flovilmart avatar Jul 16 '16 00:07 flovilmart