Skip to content

Cannot create Parse Role after "fix: return correct response when revert is used in beforeSave #7839" #8317

Closed
@AlbinIzi

Description

@AlbinIzi

New Issue Checklist

Issue Description

The PR #7839 introduce a regression. We cannot create a Parse.Role anymore if we have a beforeSave on Parse.Role.
We get an error: TypeError: Tried to create an ACL with an invalid permission type.

Steps to reproduce

Add this test in spec/CloudCode.spec.js:

  it('create role with name and ACL and a beforeSave', async () => {
    Parse.Cloud.beforeSave(Parse.Role, ({ object }) => {
      // do nothing, it's just to reproduce the bug, we must have a beforeSave
      return object;
    });

    const obj = new Parse.Role('TestRole', new Parse.ACL({ '*': { read: true, write: true } }));
    await obj.save();

    expect(obj.getACL()).toEqual(new Parse.ACL({ '*': { read: true, write: true } }));
    expect(obj.get('name')).toEqual('TestRole');
    await obj.fetch();

    expect(obj.getACL()).toEqual(new Parse.ACL({ '*': { read: true, write: true } }));
    expect(obj.get('name')).toEqual('TestRole');
  });

Actual Outcome

Message:
TypeError: Tried to create an ACL with an invalid permission type.
Stack:
at
at new ParseACL (/Users/albin/iziwork/parse-server/node_modules/parse/lib/node/ParseACL.js:69:21)
at ParseRole._handleSaveResponse (/Users/albin/iziwork/parse-server/node_modules/parse/lib/node/ParseObject.js:614:25)
at /Users/albin/iziwork/parse-server/node_modules/parse/lib/node/ParseObject.js:3183:22
at processTicksAndRejections (node:internal/process/task_queues:96:5)

Expected Outcome

The created role with the right name and ACL.

Environment

Server

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

Database

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

Client

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

Logs

Metadata

Metadata

Assignees

No one assigned

    Labels

    state:releasedReleased as stable versionstate:released-alphaReleased as alpha versionstate:released-betaReleased as beta versiontype: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