Skip to content

Should Cloud Code parameter be undefined if passed without value? #4001

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

Closed
mtrezza opened this issue Jul 6, 2017 · 1 comment
Closed

Should Cloud Code parameter be undefined if passed without value? #4001

mtrezza opened this issue Jul 6, 2017 · 1 comment

Comments

@mtrezza
Copy link
Member

mtrezza commented Jul 6, 2017

Issue Description

When calling a cloud code function via REST API and passing a parameter without value, should the request parameter be undefined in Cloud Code?

Steps to reproduce

  1. Create a Cloud Code function:
Parse.Cloud.define("checkP", function(request, response) {

    var p = request.params.p;

    if (p === undefined) {
        response.error("p not set");
        return;
    }

    response.success();
}
  1. Call the function using the REST API and pass the parameter p without value.

Expected Results

Cloud code should execute response.error("p not set");

Actual Outcome

Cloud code executes response.success();

So a double check is necessary in Cloud Code to account for value-less parameters:
if (p === undefined || p == "") {...}

Environment Setup

  • Server
    • parse-server version (Be specific! Don't say 'latest'.) : 2.5.3
    • calling REST API with postman, setting parameter key p without value
    • Localhost or remote server? (AWS, Heroku, Azure, Digital Ocean, etc): Heroku
@mtrezza mtrezza changed the title Should Cloud Code parameter be undefined if it has no value? Should Cloud Code parameter be undefined if passed without value? Jul 6, 2017
@mtrezza mtrezza closed this as completed Jul 6, 2017
@mtrezza
Copy link
Member Author

mtrezza commented Jul 6, 2017

Closed because just found out that the the URI RFC doesn't mandate a format for the query string.

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

1 participant