Skip to content

_Role afterSave validation error #2626

@michalmichalewski

Description

@michalmichalewski

New Issue Checklist


Issue Description

Adding an afterSave hook on the built-in _Role class causes a validation error, even if the hook is completely empty and makes no changes to the object.

The error is:

A role's name can only be set before it has been saved.

This seems to be triggered due to internal behavior when handling _Role objects during the afterSave lifecycle. This bug prevents any post-save logic from being used with _Role.


Steps to reproduce

  1. Add this Cloud Code to Parse:
Parse.Cloud.afterSave('_Role', async (request) => {
  // no-op
});
  1. Run the following in your client or console:
const role = new Parse.Role('Admin', new Parse.ACL());
await role.save(); // fails
  1. Observe the validation error, even though no modification is made in the hook.

Actual Outcome

save() fails with the following error:

A role's name can only be set before it has been saved.

Expected Outcome

Saving a _Role with an empty afterSave hook should succeed, as long as the name field isn't modified.


Environment

Server

  • Parse Server version: 8.1.0
  • Operating system: Ubuntu 22.04
  • Local or remote host: Remote (self-hosted, Docker)

Database

  • System: MongoDB
  • Database version: 6.0.x
  • Host: MongoDB Atlas

Client

  • "parse": "^6.1.1"

Logs

Set VERBOSE=1 but the only error printed is:

A role's name can only be set before it has been saved.

Metadata

Metadata

Assignees

No one assigned

    Labels

    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