parse-community / parse-community/parse-server

customObjectId does not work with `beforeSave` triggers

Open
#6,733 12 comments 4 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

Issue Description
  • customObjectId does not work with beforeSave triggers.
Steps to reproduce
  • Turn on flag allowCustomObjectId on ParseServer
  • Try to create a GameScore object with customObjectId objectId1 (from Android or iOS)
  • Back to ParseServer, add beforeSave trigger for GameScore with empty body / function.
  • Try to create the second GameScore object with customObjectId objectId2 (from Android or iOS)
Expected Results
  • Received 2: GameScore objects with customObjectId: objectId1, objectId2.
Actual Outcome
  • The first object has objectId is objectId1 while the second object has random id like this sMTH8Sq6jl
Environment Setup
  • Server

    • parse-server version: 4.2.0
    • Operating System: N/A
    • Hardware: N/A
    • Localhost or remote server? (AWS, Heroku, Azure, Digital Ocean, etc): The problem happens on both localhost and Heroku
  • Database

    • MongoDB version: 4.2.7
    • Storage engine: N/A
    • Hardware: N/A
    • Localhost or remote server? (AWS, mLab, ObjectRocket, Digital Ocean, etc): The problem happens on both localhost and mLab

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

Start at Parse Server's handling of object creation with allowCustomObjectId enabled and compare it with the beforeSave trigger path; reproduce the two GameScore creations described. Done means both created objects retain objectId1 and objectId2 when an empty beforeSave trigger is enabled, with a regression test covering that sequence.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, mongodb, nodejs
Domain
api, backend, database
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.