Parse-server: cloud code name cannot contain dot (.)

Created on 23 Oct 2018  路  7Comments  路  Source: parse-community/parse-server

Before opening the issue please ensure that you have:

  • [x] [Read the migration guide](https://github.com/parse-community/parse-server/blob/master/3.0.0.md) to parse-server 3.0.0
  • [x] [Read the migration guide](https://github.com/parse-community/Parse-SDK-JS/blob/master/2.0.0.md) to Parse SDK JS 2.0.0

Issue Description

naming cloud function including dot '.' produce error

Steps to reproduce

adding this line in cloud, main.js
node.js // cloud/main.js Parse.Cloud.define('customer.create', async (req) => {})

Expected Results

success without error

Actual Outcome

/Users/thee/Desktop/parse-base-system/services/data-server/node_modules/parse-server/lib/triggers.js:111
  store[lastComponent] = handler;
                       ^

TypeError: Cannot set property '[object Array]' of undefined
    at add (/Users/thee/Desktop/parse-base-system/services/data-server/node_modules/parse-server/lib/triggers.js:111:24)
    at Object.addFunction (/Users/thee/Desktop/parse-base-system/services/data-server/node_modules/parse-server/lib/triggers.js:127:3)
    at Object.ParseCloud.define (/Users/thee/Desktop/parse-base-system/services/data-server/node_modules/parse-server/lib/cloud-code/Parse.Cloud.js:42:12)
    at Object.<anonymous> (/Users/thee/Desktop/parse-base-system/services/data-server/cloud/main.js:36:13)
    at Module._compile (internal/modules/cjs/loader.js:689:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
    at Module.load (internal/modules/cjs/loader.js:599:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
    at Function.Module._load (internal/modules/cjs/loader.js:530:3)
    at Module.require (internal/modules/cjs/loader.js:637:17)
    at require (internal/modules/cjs/helpers.js:20:18)
    at new ParseServer (/Users/thee/Desktop/parse-base-system/services/data-server/node_modules/parse-server/lib/ParseServer.js:145:9)
    at Function.start (/Users/thee/Desktop/parse-base-system/services/data-server/node_modules/parse-server/lib/ParseServer.js:296:25)
    at start (/Users/thee/Desktop/parse-base-system/services/data-server/node_modules/parse-server/lib/cli/parse-server.js:84:22)
    at _default (/Users/thee/Desktop/parse-base-system/services/data-server/node_modules/parse-server/lib/cli/utils/runner.js:57:3)
    at Object.<anonymous> (/Users/thee/Desktop/parse-base-system/services/data-server/node_modules/parse-server/lib/cli/parse-server.js:38:21)

Environment Setup

  • Server

    • parse-server version (Be specific! Don't say 'latest'.) : 3.1.0
    • Operating System: OSX Heigh Sierra
    • Hardware: MacBook Air 2012
    • Localhost or remote server? (AWS, Heroku, Azure, Digital Ocean, etc): localhost
  • Database

    • MongoDB version: [FILL THIS OUT]
    • Storage engine: [FILL THIS OUT]
    • Hardware: [FILL THIS OUT]
    • Localhost or remote server? (AWS, mLab, ObjectRocket, Digital Ocean, etc): [FILL THIS OUT]

Logs/Trace

All 7 comments

I don't think you're intended to be able to. Keep in mind that cloud code functions are hit via REST API with something like <YourURL>/functions/functionName

So, the . would not be appropriate to use. I wonder, though, if a / instead would work? I'm not sure how parse-server would handle that routing, but it is worth a try.

Working as expected. Cloud functions names should not include such characters. We should be probably more explicit.

This wasn't the case in 2.8.4, could it be added to the list of breaking changes for 3.0.0?
It took me nearly a day to figure out why my code wasn't working on the new version and I'd like to avoid the pain to other people.

Would you be willing to open a pull request to address the documentation?

This should be added to the breaking changes. Dot notation was very useful to specify modules names for example. For chance i found this post otherwise I had to spent a lot of time. At least it should be shown an error like "no special characters allowed in cloud function names".

@acinader @Simone-cogno was this actually resolved?

Seems like there is no clear indication in the docs.

Also, would it be possible to add support for either . or / ?

If so, please reopen and I'll try to submit a PR

Thanks for picking this up.

Since this is over 2 years old and we have a new template for this, if you want to propose this enhancement and work on a PR, please open a new issue and reference this issue.

Was this page helpful?
0 / 5 - 0 ratings