You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Cannot create '_GlobalConfig' entry of type 'File' #3457
When trying to create a new entry in Config of type 'File', parse server does not properly store the value in config
Steps to reproduce
Please include a detailed list of steps that reproduce the issue. Include curl commands when applicable.
Create a new config value with type 'File' through the REST API
Issue a POST to /parse/config with the following body:
{
"params": {
"test": {
"__type": "File",
"name": "98a385dbd42e07c932d4d012291295cc_default_tango_sku_2.json",
"url": "https://parse-server-dev.herokuapp.com/parse/files/{App ID}/98a385dbd42e07c932d4d012291295cc_default_tango_sku_2.json"
}
},
"_method": "PUT",
"_ApplicationId": "{Application Id}",
"_ClientVersion": "js1.6.14",
"_MasterKey": "{Master Key}",
"_InstallationId": "{Installation Id}"
}
(this body was modeled after what is generated from the parse dashboard when trying to create a new config value of type 'File')
Alternatively, if you have parse dashboard set up you can use it to try to create a new config value of type 'File' and see that after reloading the page, the new value is treated as type 'String'
Expected Results
Expected result if to have a new config value named 'test' that is of type: 'File'.
Actual Outcome
Actual outcome is that a new config value called 'test' is created and is of type 'String'
Environment Setup
Server
parse-server version (Be specific! Don't say 'latest'.) : 2.3.2
Operating System: Linux
Hardware: Heroku Standard Dyno
Localhost or remote server? (AWS, Heroku, Azure, Digital Ocean, etc): Heroku
Database
MongoDB version: 3.0.12
Hardware: mlab standard
Localhost or remote server? (AWS, mLab, ObjectRocket, Digital Ocean, etc): mlab
When transforming a 'File' to be written to the database, it just writes the 'name' field of the file instead of the remaining information. I assume this works in other places within parse server (for example when a class has a field of type 'File') because the schema dictates that the field is a 'File' but on the '_GlobalConfig' object, if the name is just stored as a string then the config will be treated as a 'String' not a 'File'
Uhm... we obviously treat _GlobalConfig as any other ParseObject which is bad as it isn't backed by a shema. We should probably not transform any of the values there.
Yeah I'm happy to take a stab at fixing it. I figured there was a reason that 'Files' were being transformed in this way for other cases (for example when a 'File' is a field on a parse object) so I couldn't just alter this code.
It looks like we have access here to the className so I could add some special logic for className="_GlobalConfig" and type = 'File', does that sound reasonable?
Let's see how it looks like, or if we can extract in a more general way. Not a big fan of 'class specific' code in the transformation funcs, but something else may be problematic as well.
Activity
mross22 commentedon Jan 31, 2017
I think I have narrowed down the issue to the code in MongoTransform.js (Specifically FileCoder.JSONToDatabase):
https://github.com/ParsePlatform/parse-server/blob/4cb6e7d209903990c02e2e3f1a9bcd4aa03983aa/src/Adapters/Storage/Mongo/MongoTransform.js
When transforming a 'File' to be written to the database, it just writes the 'name' field of the file instead of the remaining information. I assume this works in other places within parse server (for example when a class has a field of type 'File') because the schema dictates that the field is a 'File' but on the '_GlobalConfig' object, if the name is just stored as a string then the config will be treated as a 'String' not a 'File'
flovilmart commentedon Jan 31, 2017
Uhm... we obviously treat _GlobalConfig as any other ParseObject which is bad as it isn't backed by a shema. We should probably not transform any of the values there.
mross22 commentedon Jan 31, 2017
Yeah I'm happy to take a stab at fixing it. I figured there was a reason that 'Files' were being transformed in this way for other cases (for example when a 'File' is a field on a parse object) so I couldn't just alter this code.
It looks like we have access here to the className so I could add some special logic for className="_GlobalConfig" and type = 'File', does that sound reasonable?
flovilmart commentedon Jan 31, 2017
Let's see how it looks like, or if we can extract in a more general way. Not a big fan of 'class specific' code in the transformation funcs, but something else may be problematic as well.
mross22 commentedon Jan 31, 2017
Sent out a PR here:
#3458
Let me know what you think when you have a chance
dplewis commentedon Jul 10, 2018
Closed via #3531