Skip to content

[CloudCode] Unsetting a ParseFile in beforeSave does not work as expected #1931

@j-koenig

Description

@j-koenig

Issue Description

On hosted Parse we had a construct in our CloudCode where we unset a ParseFile (User.thumbnail) in the beforeSave of a user object if another field in the object (User.image) was dirty. In the afterSave we then checked if the object does not have a value for the field (!User.has("thumbnail")) and then filled it with a new value. With the new setup this doesn't work anymore because !User.has("thumbnail") is never true nor is User.get("thumbnail") == null in the afterSave and therefore the thumbnail will never be set to its new value.

Today I rearranged the code so that the thumbnail generation takes place in the beforeSave but maybe there are other people struggling with this exact problem.

Steps to reproduce

  1. Use the beforeSave of the class User to unset a ParseFile-field
  2. Check if the field is empty in the afterSave with !request.object.has("fieldName")
  3. The field is neither null nor is !request.object.has("fieldName")

Expected Results

!request.object.has("fieldName") should be true in the afterSave

Actual Outcome

!request.object.has("fieldName") is false

Environment Setup

  • Server
    • parse-server version: 2.2.10
    • Operating System: OSX 10.11.5 / Amazon Linux
    • Localhost / AWS Elastic Beanstalk
  • Database
    • MongoDB version: 3.2
    • Storage engine: default
    • Localhost / AWS EC2

Metadata

Metadata

Assignees

No one assigned

    Labels

    type:bugImpaired feature or lacking behavior that is likely assumedtype:questionSupport or code-level question

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions