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

Cannot create '_GlobalConfig' entry of type 'File' #3457

Closed
mross22 opened this issue Jan 31, 2017 · 6 comments
Closed

Cannot create '_GlobalConfig' entry of type 'File' #3457

mross22 opened this issue Jan 31, 2017 · 6 comments

Comments

@mross22
Copy link

mross22 commented Jan 31, 2017

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.

  1. Create a new config value with type 'File' through the REST API
  2. 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')

  1. 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
@mross22
Copy link
Author

mross22 commented 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
Copy link
Contributor

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
Copy link
Author

mross22 commented 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
Copy link
Contributor

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
Copy link
Author

mross22 commented Jan 31, 2017

Sent out a PR here:
#3458

Let me know what you think when you have a chance

@dplewis
Copy link
Member

dplewis commented Jul 10, 2018

Closed via #3531

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants