-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Allowing restricted field names #7130
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
Comments
Thanks for opening this issue. I support this discussion because it seems best practice to not make the developer having to consider Parse Server's internal keys. Do you want to look into what is causing the current restriction of the |
We just had a look at the Parse Server code and unfortunately, this is a bit over our heads. The I think a good fix for us would be to ensure that the Maybe someone has knowledge about the order in which errors and |
Are you sure the hook is not being called before the error is thrown? Would you mind to write a failing test case for this scenario? |
Ok. How? |
You can take a look at the basic beforeSave tests on how to write such a test: parse-server/spec/CloudCode.spec.js Lines 75 to 91 in d47891f
Side note, most tests are in the old chained promise syntax, for new tests we should use await/async syntax. |
One way to separate For example, a ParseObject can have a symbol Another, more platform-universal way, may be to just add the properties to an encapsulating super-property of ParseObject. |
FWIW, I'm attempting to fix this with the following job, which replaces my "length" property. On my end "length" represented a length of time in minutes, so I'm replacing with "lengthInMin". Have to run this job on downgraded Parse Server before making the full upgrade to 4.5. (It's currently running for 200k objects..) `Parse.Cloud.job('replaceLengthForAllObjects', async request => {
|
You could actually do that with a script directly on the MongoDB server, with a fraction of resources, because you don't need the Parse overhead. |
New Issue Checklist
Issue Description
We updated Parse Server to version 4.5.0, and included in the latest security changes, now we can not use certain restricted fields like
length
orclassName
as this merged PR explains: #7053We have a class in production since Parse Server 3.0.0 that has been using the newly restricted field
length
so now we can not create or edit objects of that class as Parse returns an error:{Invalid field name: length., code=105}
As a workaround, we've tried to unset the length key in a beforeSave hook of that class. That works great for any object which is newly created, but not for object updates (tested with REST API POST and PUT). When updating an object, the beforeSave hook is not called, and Parse Server returns an error before we can unset the key.
This issue attempts to open a discussion about how to work this concept out. As suggested by @mtrezza we could allow the "reserved" field names by encoding fields differently in the Parse Object. #7053 (comment)
Steps to reproduce
Create a class in Parse Server 4.4.1 (or anything lower than 4.5.0) with the field
length
.Create some objects for that class.
Update Parse Server to (4.5.0).
Attempt editing those objects or creating new ones by REST API POST and PUT, or from Parse dashboard.
Actual Outcome
The object can not be created or edited:
{Invalid field name: length., code=105}
Expected Outcome
The object is successfully created or edited.
Environment
Server
4.5.0
Linux
Heroku
Database
MongoDB
4.4.3
mLab
Client
iOS
1.19.0
Logs
From iOS: Error Domain=Parse Code=105 "Invalid field name: length." UserInfo={error=Invalid field name: length., NSLocalizedDescription=Invalid field name: length., code=105}
The text was updated successfully, but these errors were encountered: