Skip to content

Deeply nested keys are not passed correctly to afterSave triggers #7384

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

Open
5 of 6 tasks
mstniy opened this issue May 12, 2021 · 5 comments
Open
5 of 6 tasks

Deeply nested keys are not passed correctly to afterSave triggers #7384

mstniy opened this issue May 12, 2021 · 5 comments
Labels
type:bug Impaired feature or lacking behavior that is likely assumed

Comments

@mstniy
Copy link
Contributor

mstniy commented May 12, 2021

New Issue Checklist

Issue Description

afterSave triggers do not receive the correct updated object, if a deeply nested key was updated.

Steps to reproduce

  1. Create an afterSave trigger for a class
  2. Create a document with a deeply nested key:
const obj = new Parse.Object('GameScore');
obj.set('a', {'b':{'c':0}});
await obj.save();
  1. Change the deeply nested key
obj.set('a.b.c', 1);
await obj.save();

Actual Outcome

The afterSave triggers receives a wrong object (in request.object)

Expected Outcome

In the trigger call for the second save(), the field a of the received object should be {'b':{'c':1}}

Failing Test Case / Pull Request

  • 🤩 I submitted a PR with a fix and a test case.
  • 🧐 I submitted a PR with a failing test case.

Environment

Server

  • Parse Server version: Latest commit as of 12 May 2021, 51e0800
  • Operating system: any
  • Local or remote host (AWS, Azure, Google Cloud, Heroku, Digital Ocean, etc): local

Database

  • System (MongoDB or Postgres): MongoDB
  • Database version: v4.4.5
  • Local or remote host (MongoDB Atlas, mLab, AWS, Azure, Google Cloud, etc): local

Client

  • SDK (iOS, Android, JavaScript, PHP, Unity, etc): any
  • SDK version: any

Logs

@mtrezza
Copy link
Member

mtrezza commented May 12, 2021

Thanks for reporting.

Can you specify what exactly that wrong object is according to your example?

The afterSave triggers receives a wrong object (in request.object)

@mstniy
Copy link
Contributor Author

mstniy commented May 12, 2021

@mtrezza The trigger gets {"a":{"b":1}
Inspecting the code, it completely ignores any depth further than the first two, so in this example, a and b make it, but c gets dropped.

@mtrezza
Copy link
Member

mtrezza commented May 20, 2021

Thanks for the details. I classify this as bug with severity S3, because a workaround exists.

Workaround: Pass object / field via trigger context.

@mtrezza mtrezza added type:bug Impaired feature or lacking behavior that is likely assumed S3 labels May 20, 2021
mstniy added a commit to Ocell-io/parse-server that referenced this issue Oct 21, 2021
@mstniy
Copy link
Contributor Author

mstniy commented Oct 21, 2021

The issue remains even after #7005
https://github.com/Ocell-io/parse-server/tree/deep_7384_test_only demonstrates this.
#7385 is the approach our team is still using, as we make heavy use of afterSave triggers and deeply nested keys, but it doesn't seem to work with Postgre, and we don't have the resources to investigate into it. Thus, I have marked it as a draft.

@ArkeshGKalathiya
Copy link

ArkeshGKalathiya commented Nov 29, 2021

Possibly because of this bug, live queries also don't work properly, and there is no work around for that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:bug Impaired feature or lacking behavior that is likely assumed
Projects
None yet
Development

No branches or pull requests

3 participants