Skip to content

Error 500 on delete schema #1919

Closed
Closed
@notentered

Description

@notentered

Deleting a schema throws error 500 (Internal server error.) if there are some CLPs defined for the class.

The schema got deleted, but the error is still thrown. It looks like mongoSchema[field].startsWith('relation<') is ran for the _metadata attribute and it shouldn't be.

Steps to reproduce

  1. Create schema
curl -X POST \
-H "X-Parse-Application-Id: WB_API" \
-H "X-Parse-Master-Key: superSecretMasterKey" \
-H "Content-Type: application/json" \
-d '
{
  "className": "City",
  "fields": {
  "name": {
    "type": "String"
  }
}
}' \
  http://localhost:1337/parse/schemas/City
  1. The schema is created without explicit CLPs. You can see that in the Mongo database _SCHEMA, where the definition for this class have not _metadata attribute
    parse_mongo_1
  2. Create any CPLs for the class
    parse_clps
  3. The class now have _metadata in Mongo _SCHEMA
    parse_mongo_2
  4. Delete the class
curl -X DELETE \
-H "X-Parse-Application-Id: WB_API" \
-H "X-Parse-Master-Key: superSecretMasterKey" \
-H "Content-Type: application/json" \
  http://localhost:1337/parse/schemas/City

Expected Results

The class is deleted. No errors.
Note: The class have no objects.

Actual Outcome

The class is deleted, but Error 500 is thrown.

{"code":1,"message":"Internal server error."}

Environment Setup

  • Server
    • parse-server version: 2.2.10
    • Operating System: OSX 10.11.5
    • Localhost or remote server? Localhost
  • Database
    • MongoDB version: 3.2.5
    • Storage engine: wiredTiger
    • Localhost or remote server? Localhost

Logs/Trace

error: Uncaught internal server error. [TypeError: mongoSchema[field].startsWith is not a function] TypeError: mongoSchema[field].startsWith is not a function
    at /Users/zlatko/Projects/wattbikehub-api/node_modules/parse-server/lib/Routers/SchemasRouter.js:99:31
    at Array.filter (native)
    at removeJoinTables (/Users/zlatko/Projects/wattbikehub-api/node_modules/parse-server/lib/Routers/SchemasRouter.js:97:47)
    at /Users/zlatko/Projects/wattbikehub-api/node_modules/parse-server/lib/Routers/SchemasRouter.js:122:12
    at run (/Users/zlatko/Projects/wattbikehub-api/node_modules/parse-server/node_modules/babel-polyfill/node_modules/core-js/modules/es6.promise.js:89:22)
    at /Users/zlatko/Projects/wattbikehub-api/node_modules/parse-server/node_modules/babel-polyfill/node_modules/core-js/modules/es6.promise.js:102:28
    at flush (/Users/zlatko/Projects/wattbikehub-api/node_modules/parse-server/node_modules/babel-polyfill/node_modules/core-js/modules/_microtask.js:18:9)
    at nextTickCallbackWith0Args (node.js:420:9)
    at process._tickDomainCallback (node.js:390:13)

Metadata

Metadata

Assignees

No one assigned

    Labels

    type:bugImpaired feature or lacking behavior that is likely assumed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions