Skip to content

Parse.Object.saveAll() does not propagate sessionToken for all objects being saved #3665

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
rdbayer opened this issue Mar 23, 2017 · 14 comments
Assignees
Labels
type:question Support or code-level question

Comments

@rdbayer
Copy link
Contributor

rdbayer commented Mar 23, 2017

When calling Parse.Object.saveAll(array, {sessionToken: request.user.getSessionToken()}), only the first object would be saved successfully, while later objects would encounter an 'Object not found' error.

If I instead do a Parse.Promise.when where I save each object individually with the sessionToken, it works fine. Another workaround is using {useMasterKey: true} instead of the session token.

Neither of these workarounds should be necessary though.

@flovilmart
Copy link
Contributor

Do you have server logs when running with VERBOSE=1 please?

@rdbayer
Copy link
Contributor Author

rdbayer commented Mar 23, 2017

Here are what I think are the relevant parts. Let me know if you're looking for something else.

Request

verbose: REQUEST for [POST] /parse/batch: {
  "requests": [
    {
      "method": "PUT",
      "body": {
        "status": 1
      },
      "path": "/parse/classes/UserTactic/GctM5PJpU0"
    },
    {
      "method": "PUT",
      "body": {
        "status": 1
      },
      "path": "/parse/classes/UserTactic/1QdvG2b2mE"
    },
    {
      "method": "PUT",
      "body": {
        "status": 1
      },
      "path": "/parse/classes/UserTactic/Pczihj8ACH"
    },
    {
      "method": "PUT",
      "body": {
        "status": 1
      },
      "path": "/parse/classes/UserTactic/cB6gmBgHpK"
    },
    {
      "method": "PUT",
      "body": {
        "status": 1
      },
      "path": "/parse/classes/UserTactic/P8PDqVdHwk"
    }
  ]
} method=POST, url=/parse/batch, user-agent=node-XMLHttpRequest, Parse/js1.9.2 (NodeJS 6.9.5), accept=*/*, content-type=text/plain, host=localhost:1337, content-length=652, connection=close, requests=[method=PUT, status=1, path=/parse/classes/UserTactic/GctM5PJpU0, method=PUT, status=1, path=/parse/classes/UserTactic/1QdvG2b2mE, method=PUT, status=1, path=/parse/classes/UserTactic/Pczihj8ACH, method=PUT, status=1, path=/parse/classes/UserTactic/cB6gmBgHpK, method=PUT, status=1, path=/parse/classes/UserTactic/P8PDqVdHwk]

Response

verbose: RESPONSE from [POST] /parse/batch: {
  "response": [
    {
      "error": {
        "code": 101,
        "error": "Object not found."
      }
    },
    {
      "error": {
        "code": 101,
        "error": "Object not found."
      }
    },
    {
      "error": {
        "code": 101,
        "error": "Object not found."
      }
    },
    {
      "error": {
        "code": 101,
        "error": "Object not found."
      }
    },
    {
      "success": {
        "updatedAt": "2017-03-23T23:51:36.110Z"
      }
    }
  ]
} response=[code=101, error=Object not found., code=101, error=Object not found., code=101, error=Object not found., code=101, error=Object not found., updatedAt=2017-03-23T23:51:36.110Z]

Extra Info

In case it helps, I should also mention that the context is that this is executing from within a cloud function (Parse.Cloud.define())

@Jeff2017
Copy link

Same here. I tried parse-server 2.3.2 and 2.3.7. I didn't use cloud code, just created a https server with databaseURI assigned to 'mongoldb://localhost:27017/parse'

save/saveEventually works fine for each one, but saveAll will save the first one and report 'Object not found' for others.

flovilmart added a commit that referenced this issue May 16, 2017
@flovilmart
Copy link
Contributor

flovilmart commented May 16, 2017

@rdbayer
Copy link
Contributor Author

rdbayer commented May 16, 2017

Whoops, sorry, made my previous (deleted) comment without reading the second part of your test :)

My only additional thought is that in my specific case, the ACL I'm relying on is for a Role, so maybe the bug is Role-specific?

@flovilmart
Copy link
Contributor

Ah so you have a role then, not an ACL for a particular user right?

@rdbayer
Copy link
Contributor Author

rdbayer commented May 16, 2017

Yeah, to be even more precise, in my specific repro, the ACL allows permissions for role X and user Y, and the session token (that doesn't seem to get propagated correctly) is for user Z who has role X.

@flovilmart
Copy link
Contributor

flovilmart commented May 16, 2017

Updated the test, with User A with Role 'admin', and objects with role read/write, and still no issue. Even with an additional user having R/W on it.
Could you post some example data / a gist with an example that fails? I am not able to reproduce this issue.

@flovilmart flovilmart self-assigned this May 16, 2017
@rdbayer
Copy link
Contributor Author

rdbayer commented May 16, 2017

I think the only difference left in my case is that the ACL also has read/write permission (for a user other than user A, in addition to the Role read/write permission), so perhaps that could somehow be causing an issue? But if that doesn't cause a repro, I'm out of ideas as to why I see it but you don't :-/

@flovilmart
Copy link
Contributor

Do you have Class Level permissions or something else? Again, if you could post a gist with example data, that would help. I can confirm the session token is properly passed through, and propagated. The full auth state from the original request is actually propagated to the batch'd elements.

@rdbayer
Copy link
Contributor Author

rdbayer commented May 16, 2017

Yes, I do indeed have class permissions (public can Create only, Admin role can full read/write, 'user' pointer column can full read/write)

@flovilmart
Copy link
Contributor

OK, I'll try to replicate with CLP

@stale
Copy link

stale bot commented Sep 18, 2018

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

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

4 participants