Skip to content

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

Closed

Description

@mross22

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

Activity

  1. mross22 commented on Jan 31, 2017

    @mross22
    Author

    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'

  2. flovilmart commented on Jan 31, 2017

    @flovilmart
    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.

  3. mross22 commented on Jan 31, 2017

    @mross22
    Author

    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?

  4. flovilmart commented on Jan 31, 2017

    @flovilmart
    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.

  5. mross22 commented on Jan 31, 2017

    @mross22
    Author

    Sent out a PR here:
    #3458

    Let me know what you think when you have a chance

  6. dplewis commented on Jul 10, 2018

    @dplewis
    Member

    Closed via #3531

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions