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

Current user endpoint returns unexpected additional attributes #3348

Closed
francisjervis opened this issue Jan 10, 2017 · 2 comments
Closed

Current user endpoint returns unexpected additional attributes #3348

francisjervis opened this issue Jan 10, 2017 · 2 comments

Comments

@francisjervis
Copy link

francisjervis commented Jan 10, 2017

Describe your issue in as much detail as possible.

When accessing the current user from a Parse Server installation, the keys

"__type": "Object",
"className": "_User","

are added. These keys are not included in the data returned from the Parse hosted API endpoint. Their inclusion causes unexpected behavior/crashes in implementations relying on the REST API pointed at a Parse Server instance.

Steps to reproduce

Make a request to /user/me on a Parse Server instance, eg.

curl -X GET -H "X-Parse-Application-Id: {{HOSTEDAPPLICATIONID}}" -H "X-Parse-REST-API-Key: {{HOSTEDRESTKEY}}" -H "X-Parse-Session-Token: {{HOSTEDSESSION}}" -H "Cache-Control: no-cache" -H "Postman-Token: 12283aad-8662-88f2-34f7-77f73f504c76" "https://api.parse.com/1/users/me"

returns the expected result.

Running
curl -X GET -H "X-Parse-Application-Id: {{PSAPPLICATIONID}}" -H "X-Parse-REST-API-Key: {{PSRESTKEY}}" -H "X-Parse-Session-Token: {{PSSESSION}}" -H "Cache-Control: no-cache" -H "Postman-Token: 12283aad-8662-88f2-34f7-77f73f504c76" "https://api.myparseserver.com/parse/users/me"

on a Parse Server instance with the same user data returns the user object with the unexpected keys appended.

Expected Results

Return a complete user object.

Actual Outcome

User object is returned, but with the __type and className attributes appended.
This causes eg. the following crash in the parse-rest library:
milesrichardson/ParsePy#155

Environment Setup

  • Server

    • parse-server version 2.3.1
    • Operating System: Ubuntu, Mac OS
    • Localhost or remote server? Local & Cloud9
  • Database

    • MongoDB version: [FILL THIS OUT]
    • Storage engine: [FILL THIS OUT]
    • Hardware: [FILL THIS OUT]
    • Localhost or remote server? (AWS, mLab, ObjectRocket, Digital Ocean, etc): [FILL THIS OUT]

Logs/Trace

cURL returns the following for a test user from the API
{
"completedTaskCount": 2,
"createdAt": "2015-08-28T05:53:51.522Z",
"createdExchange": {
"__type": "Relation",
"className": "Exchanges"
},
"customerId": "cus****BuL",
"email": "[email protected]",
"emailVerified": false,
"exchangeCount": 6,
"firstName": "first",
"fridayDisabled": false,
"fridayEnd": 2000,
"fridayStart": 800,
"isContact": {
"__type": "Relation",
"className": "_User"
},
"lastGeoPoint": {
"__type": "GeoPoint",
"latitude": 37.39386029386699,
"longitude": -122.0415564821301
},
"lastName": "last",
"locationText": "Brooklyn, New York",
"memberOfExchange": {
"__type": "Relation",
"className": "Exchanges"
},
"mondayDisabled": true,
"mondayEnd": 2000,
"mondayStart": 800,
"objectId": "z7F2SmxzhY",
"prefExchangeMessages": true,
"prefJoinExchanges": true,
"prefJoinExchangesEmails": true,
"prefMatchEmails": true,
"prefMatchNotifications": true,
"prefNewExchanges": true,
"prefNewExchangesEmails": true,
"prefPrivateMessages": true,
"prefShowEmail": true,
"prefShowPhone": true,
"prefShowTotalTime": true,
"prefTaskEmails": true,
"prefTaskNotifications": true,
"profilePicture": {
"__type": "Pointer",
"className": "profilePictures",
"objectId": "PG1jDq0Eoa"
},
"profileText": "",
"saturdayDisabled": false,
"saturdayEnd": 2400,
"saturdayStart": 800,
"sessionToken": "r:Wz*****jL",
"sundayDisabled": false,
"sundayEnd": 2400,
"sundayStart": 800,
"thursdayDisabled": true,
"thursdayEnd": 2000,
"thursdayStart": 800,
"timeZoneId": "America/Los_Angeles",
"totalSeconds": 10808,
"tuesdayDisabled": false,
"tuesdayEnd": 2000,
"tuesdayStart": 800,
"updatedAt": "2017-01-04T14:26:42.058Z",
"username": "[email protected]",
"waitingToJoinExchange": {
"__type": "Relation",
"className": "Exchanges"
},
"wednesdayDisabled": false,
"wednesdayEnd": 2000,
"wednesdayStart": 800
}

And from Parse Server

{
"objectId": "z7F2SmxzhY",
"emailVerified": false,
"username": "[email protected]",
"createdAt": "2015-08-28T05:53:51.522Z",
"_perishable_token": "HBTAQ",
"_email_verify_token": "9N7
qJwcv",
"updatedAt": "2017-01-04T14:26:42.058Z",
"email": "[email protected]",
"prefShowTotalTime": true,
"mondayEnd": 2000,
"sundayStart": 800,
"prefExchangeMessages": true,
"sundayEnd": 2400,
"prefTaskNotifications": true,
"completedTaskCount": 2,
"saturdayStart": 800,
"saturdayEnd": 2400,
"prefPrivateMessages": true,
"thursdayStart": 800,
"wednesdayEnd": 2000,
"prefShowEmail": true,
"prefNewExchanges": true,
"tuesdayStart": 800,
"fridayStart": 800,
"thursdayEnd": 2000,
"wednesdayStart": 800,
"fridayEnd": 2000,
"prefShowPhone": true,
"prefJoinExchanges": true,
"exchangeCount": 6,
"mondayStart": 800,
"tuesdayEnd": 2000,
"prefMatchNotifications": true,
"locationText": "Brooklyn, New York",
"firstName": "first",
"lastName": "last",
"lastGeoPoint": {
"__type": "GeoPoint",
"latitude": 37.39386029386699,
"longitude": -122.0415564821301
},
"prefJoinExchangesEmails": true,
"prefMatchEmails": true,
"prefNewExchangesEmails": true,
"prefTaskEmails": true,
"profilePicture": {
"__type": "Pointer",
"className": "profilePictures",
"objectId": "PG1jDq0Eoa"
},
"profileText": "",
"timeZoneId": "America/Los_Angeles",
"customerId": "cus_8uL",
"mondayDisabled": true,
"wednesdayDisabled": false,
"fridayDisabled": false,
"thursdayDisabled": true,
"sundayDisabled": false,
"saturdayDisabled": false,
"tuesdayDisabled": false,
"totalSeconds": 10808,
"isContact": {
"__type": "Relation",
"className": "_User"
},
"createdExchange": {
"__type": "Relation",
"className": "Exchanges"
},
"waitingToJoinExchange": {
"__type": "Relation",
"className": "Exchanges"
},
"memberOfExchange": {
"__type": "Relation",
"className": "Exchanges"
},
"__type": "Object",
"className": "_User",
"sessionToken": "r:d
**0"
}

@milesrichardson
Copy link

FYI I fixed this issue on my end (milesrichardson/ParsePy#155)

Personally I don't consider it to be the responsibility of parse-server... libraries shouldn't break because new keys are added to responses.

This edge case was a bug because the python library had a native attribute called className, so when trying to convert from parse JSON to a native object, setting the className property raised an attribute error. This only happened with the User class because the python code implements User class separately from all other objects, and only User class had a conflicting className key.

@flovilmart
Copy link
Contributor

Closing as resolved in ParsePy

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

3 participants