Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unsaved children does not work for unsaved Parse.File #1660

Closed
4 tasks done
swittk opened this issue Jan 23, 2023 · 3 comments · Fixed by #1662
Closed
4 tasks done

unsaved children does not work for unsaved Parse.File #1660

swittk opened this issue Jan 23, 2023 · 3 comments · Fixed by #1662
Labels
type:bug Impaired feature or lacking behavior that is likely assumed

Comments

@swittk
Copy link
Contributor

swittk commented Jan 23, 2023

New Issue Checklist

Issue Description

When saving a new Parse.Object that is saved with a new Parse.File, the following error occurs.

TypeError: object._getId is not a function. (In 'object._getId()', 'object._getId' is undefined)

Likely it's from _getId() not being implemented for the ParseFile class? Since _getId() is called here when saving unsaved children.

const identifier = obj.className + ':' + obj._getId();

Steps to reproduce

// a File object
const file : File;
const parseFile = new Parse.File('myFileName',  file);
const parseObject = new Parse.Object({ prop1: "hello", file: parseFile });
parseObject.save();

Actual Outcome

TypeError: object._getId is not a function. (In 'object._getId()', 'object._getId' is undefined)

Expected Outcome

No errors

Environment

Node.js v16.13.1

Server

  • Parse Server version: ^5.4.0
  • Operating system: Mac OS Monterey 12.5.1, Ubuntu 22.04
  • Local or remote host (AWS, Azure, Google Cloud, Heroku, Digital Ocean, etc): Local network served Node.JS

Database

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

Client

  • Parse JS SDK version: 3.5.1

Logs

TypeError: object._getId is not a function. (In 'object._getId()', 'object._getId' is undefined)

@parse-github-assistant
Copy link

Thanks for opening this issue!

  • 🚀 You can help us to fix this issue faster by opening a pull request with a failing test. See our Contribution Guide for how to make a pull request, or read our New Contributor's Guide if this is your first time contributing.

@swittk
Copy link
Contributor Author

swittk commented Jan 23, 2023

I've pinpointed the source of the crash to this line of code

const objectId = object.objectId || object._getId();

Would it be possible if we just added a check for Parse.File here?

@swittk
Copy link
Contributor Author

swittk commented Jan 23, 2023

The call appears to be localDatastore._updateLocalIdForObject (which is here). And the call is from ParseObject's save method (specifically here)

I've found that adding a check for if(object instanceof ParseObject) covering these two lines solves the issue

await localDatastore._updateLocalIdForObject(mapIdForPin[object.id], object);
await localDatastore._updateObjectIfPinned(object);

Should I open a pull request?

swittk added a commit to swittk/Parse-SDK-JS that referenced this issue Jan 23, 2023
Fixes parse-community#1660 (Caused by passing a Parse.File into the LocalDataStore, which is unexpected)
@mtrezza mtrezza added the type:bug Impaired feature or lacking behavior that is likely assumed label Jan 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:bug Impaired feature or lacking behavior that is likely assumed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants