Skip to content

Create object behaviour change from 2.2.17 to 2.2.18 #2570

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

Closed
3 of 4 tasks
btanev opened this issue Aug 23, 2016 · 9 comments
Closed
3 of 4 tasks

Create object behaviour change from 2.2.17 to 2.2.18 #2570

btanev opened this issue Aug 23, 2016 · 9 comments
Labels
type:question Support or code-level question

Comments

@btanev
Copy link

btanev commented Aug 23, 2016

Please read the following instructions carefully.

Check out #1271 for an ideal bug report.
The closer your issue report is to that one, the more likely we are to be able to help, and the more likely we will be to fix the issue quickly!

Many members of the community use Stack Overflow and Server Fault to ask questions.
Read through the existing questions or ask your own!

For database migration help, please file a bug report at https://parse.com/help#report

Make sure these boxes are checked before submitting your issue -- thanks for reporting issues back to Parse Server!

Issue Description

After updating to parse-server 2.2.18 I've notice a behaviour change when creating an Object using the REST API. In the 2.2.18 the response is missing the additional object fields and contains only the common fields like objectId, createdAt, ACL

Steps to reproduce

Common setup

We have one class defined in the schema e.g. Author that have only one field displayName.

Using parse-server 2.2.17

  1. Request
POST https://<serverUrl>/parse/classes/Author
X-Parse-Application-Id:<applicationId>
X-Parse-Master-Key:<masterKey>

{"displayName": "a test 2.2.17"}
  1. Response
HTTP/1.1 201 Created
X-Powered-By: Express
Location: https://<serverUrl>/parse/classes/Author/HAy5pEcw5c
ETag: W/"c7-8imG5HhXN6+NNJ9Fq9R14Q"
{
    "objectId": "HAy5pEcw5c",
    "createdAt": "2016-08-23T10:37:15.062Z",
    "ACL": {
        "*": {
            "read": true
        },
        "role:Admin": {
            "read": true,
            "write": true
        }
    },
    "displayName": "a test 2.2.17",
    "updatedAt": "2016-08-23T10:37:15.062Z"
}

Using parse-server 2.2.18

  1. Request
POST https://<serverUrl>/parse/classes/Author
X-Parse-Application-Id:<applicationId>
X-Parse-Master-Key:<masterKey>

{"displayName": "a test 2.2.18"}
  1. Response
HTTP/1.1 201 Created
X-Powered-By: Express
Location: https://<serverUrl>/parse/classes/Author/w3xGbKIF4O
ETag: W/"82-/MIA4WGnKv9M4f9+zrku7A"
{
    "objectId": "w3xGbKIF4O",
    "createdAt": "2016-08-23T10:51:02.525Z",
    "ACL": {
        "*": {
            "read": true
        },
        "role:Admin": {
            "read": true,
            "write": true
        }
    }
}

As you can see the fields displayName and updatedAt are missing from the response.

Question

Is this an expected behaviour? I haven't read about this change in the changelog from 2.2.17 to 2.2.18

We've found this problem after upgrading to 2.2.18 and executing our integration tests.

@mmazzarolo
Copy link

mmazzarolo commented Aug 23, 2016

Having the same issue on 2.2.18 (2.2.17 works correctly).

@joeyslack
Copy link

Indeed. Having to use 2.2.17 currently.

@flovilmart
Copy link
Contributor

That's odd indeed. it wasn't supposed to be affected.

@flovilmart
Copy link
Contributor

I'll have a looks tonight and try to provide a patch ASAP

@flovilmart flovilmart added type:bug Impaired feature or lacking behavior that is likely assumed troubleshooting labels Aug 23, 2016
@flovilmart
Copy link
Contributor

Issue originates from: e4c2e65#diff-3646535e0655c134862bb00401c8097cR942

Fix don't seem trivial

flovilmart referenced this issue Aug 23, 2016
* test case to check beforeSave changes clobbers fetched pointer fields
Basically if beforeSave makes any changes to the object it is trying to save, the fetched pointer fields on the client gets clobbered to only pointer.

* propogate only changed fields to response.
Earlier we were returning all fields even if any changes happened in beforeSave. This causes the fetched pointer fields on the client to get clobbered to only pointers.
This fix returns only the changed fields thus avoiding pointer clobber.

* The goal of this comparision seems to be checking that the all returns the user correctly.
Also it is consistent with the hosted parse that user.username not returned from PUT request.
@flovilmart
Copy link
Contributor

@btanev alright, went back a bit, checking here: http://parseplatform.github.io/docs/rest/guide/#creating-objects the REST call should only return createdAt and objectId, as well as keys that have been set by Cloud Code hooks.

The behaviour < 2.2.18 was 'broken'.

@btanev
Copy link
Author

btanev commented Aug 25, 2016

Hi @flovilmart

If it is by spec then it is by spec. Thanks for checking this out.

Do you guys have in your backlog items that are going to change this behaviour?

Can I suggest a change in the behaviour of POST and PUT requests? If they are returning the "changed" fields this will reduce the requests to the server. Right now in 2.2.18+ we have to do a POST / PUT and then to make sure we have the correct Object state we have to do a follow up GET request.

@flovilmart
Copy link
Contributor

flovilmart commented Aug 25, 2016

@btanev We should not change that behaviour in the future, there still maybe some quirks that don't match with the original documentation, so when in doubt, I ever go back to the original documentation.

As it's stated, it should only return changed fields as well as createdAt and objectId on POST, updatedAt on PUT.

If it isn't we should make sure that it the case, I believe there is a test that covers it (https://github.com/ParsePlatform/parse-server/blob/master/spec/ParseAPI.spec.js#L819)

@flovilmart flovilmart removed type:bug Impaired feature or lacking behavior that is likely assumed in-process labels Aug 25, 2016
@flovilmart
Copy link
Contributor

@btanev, i'm closing that one as the behavior is what's expected from the documentation

@mtrezza mtrezza added type:question Support or code-level question and removed 🔧 troubleshooting labels Jul 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:question Support or code-level question
Projects
None yet
Development

No branches or pull requests

5 participants