parse-community / parse-community/parse-server

Deeply nested keys are not passed correctly to afterSave triggers

Open
#7,384 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

type:bug
Dominant language
JavaScript
Stars
21.4k
Forks
4.8k
Avg merge
7h 45m
Merged PRs (30d)
11

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue by saving an object with a deeply nested key, changing it with obj.set('a.b.c', 1), and saving again. Inspect the afterSave trigger's request.object and verify that a contains {'b':{'c':1}}; the issue body indicates that a fix and test case were already submitted.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, mongodb, nodejs
Domain
api, backend, databases
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.