Skip to content

Error when updating an existing object with context #6905

Closed
@marcinjakubowski

Description

@marcinjakubowski

New Issue Checklist

Issue Description

In cloud code, when trying to update an existing object in an afterSave trigger with a context set on call to save, an error is reported and update does not go through. Seems to be some sort of a regression to #6735.

Steps to reproduce

Use the following cloud code:

Parse.Cloud.afterSave('TestObject1', async (request) => {
    const TestObj2 = Parse.Object.extend('TestObject2');
    const query = new Parse.Query(TestObj2);
    const obj = await query.first();

    return obj.save(null, { useMasterKey: true, context: { op: 'auto' } })
});
  1. Create a new class called TestObject2 and a new object of that class.
  2. Create a new class callsed TestObject1 and a new object of that class.
  3. afterSave trigger from cloud code above will trigger and fail with the error below.

Actual Outcome

Error is reported, object is not saved:

error: afterSave failed for TestObject1 for user undefined: 
  Error: {"message":"Invalid field name: _context.","code":105} {"className":"TestObject1","triggerType":"afterSave","error":{"message":"Invalid field name: _context.","code":105}}
warn: afterSave caught an errorInvalid field name: _context. {"code":105,"stack":"Error: Invalid field name: _context.\n    at handleError (/home/myak/src/github/parse-server/node_modules/parse/lib/node/RESTController.js:402:17)\n    at process._tickCallback (internal/process/next_tick.js:68:7)"}

Expected Outcome

Object is saved, context is available in beforeSave trigger on TestObject1.

Environment

Server

  • Parse Server version: 4.3.0
  • Operating system: Linux
  • Local or remote host (AWS, Azure, Google Cloud, Heroku, Digital Ocean, etc): FILL_THIS_OUT

Database

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

Client

  • SDK (iOS, Android, JavaScript, PHP, Unity, etc): n/a
  • SDK version: n/a

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions