Skip to content

Internal server error on set followed by unset #1798

Open
@mstniy

Description

@mstniy

New Issue Checklist

Issue Description

Setting a subdocument entirely, followed by an unset of a nested field causes an internal server error while the object is being saved, if the object existed beforehand.

Steps to reproduce

const myObj = new Parse.Object('MyClass');
await myObj.save(null, {useMasterKey: true});
myObj.set('data', {a: 5});
myObj.unset('data.a');
await myObj.save(null, {useMasterKey: true});
console.log('a');

Actual Outcome

error: Uncaught internal server error. Updating the path 'data.a' would create a conflict at 'data' {"code":40,"codeName":"ConflictingUpdateOperators","ok":0,"stack":"MongoServerError: Updating the path 'data.a' would create a conflict at 'data'\n    at Connection.onMessage (/home/kartal/Desktop/ocell/parse-server-example/node_modules/parse-server/node_modules/mongodb/lib/cmap/connection.js:202:30)\n    at MessageStream.<anonymous> (/home/kartal/Desktop/ocell/parse-server-example/node_modules/parse-server/node_modules/mongodb/lib/cmap/connection.js:62:60)\n    at MessageStream.emit (events.js:400:28)\n    at processIncomingData (/home/kartal/Desktop/ocell/parse-server-example/node_modules/parse-server/node_modules/mongodb/lib/cmap/message_stream.js:108:16)\n    at MessageStream._write (/home/kartal/Desktop/ocell/parse-server-example/node_modules/parse-server/node_modules/mongodb/lib/cmap/message_stream.js:28:9)\n    at writeOrBuffer (internal/streams/writable.js:358:12)\n    at MessageStream.Writable.write (internal/streams/writable.js:303:10)\n    at Socket.ondata (internal/streams/readable.js:731:22)\n    at Socket.emit (events.js:400:28)\n    at addChunk (internal/streams/readable.js:293:12)"}
MongoServerError: Updating the path 'data.a' would create a conflict at 'data'
    at Connection.onMessage (/home/kartal/Desktop/ocell/parse-server-example/node_modules/parse-server/node_modules/mongodb/lib/cmap/connection.js:202:30)
    at MessageStream.<anonymous> (/home/kartal/Desktop/ocell/parse-server-example/node_modules/parse-server/node_modules/mongodb/lib/cmap/connection.js:62:60)
    at MessageStream.emit (events.js:400:28)
    at processIncomingData (/home/kartal/Desktop/ocell/parse-server-example/node_modules/parse-server/node_modules/mongodb/lib/cmap/message_stream.js:108:16)
    at MessageStream._write (/home/kartal/Desktop/ocell/parse-server-example/node_modules/parse-server/node_modules/mongodb/lib/cmap/message_stream.js:28:9)
    at writeOrBuffer (internal/streams/writable.js:358:12)
    at MessageStream.Writable.write (internal/streams/writable.js:303:10)
    at Socket.ondata (internal/streams/readable.js:731:22)
    at Socket.emit (events.js:400:28)
    at addChunk (internal/streams/readable.js:293:12)

Expected Outcome

The object should be saved to the database with data = {}

Environment

Server

  • Parse Server version: 5.3.0
  • Operating system: ubuntu 20.04
  • Local or remote host (AWS, Azure, Google Cloud, Heroku, Digital Ocean, etc): local

Database

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

Client

  • SDK (iOS, Android, JavaScript, PHP, Unity, etc): parse dashboard
  • SDK version: 4.1.4

Logs

Metadata

Metadata

Assignees

No one assigned

    Labels

    bounty:$20Bounty applies for fixing this issue (Parse Bounty Program)type:bugImpaired feature or lacking behavior that is likely assumed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions