apache / openwhisk

Apache OpenWhisk is an open source serverless cloud platform
https://openwhisk.apache.org/
Apache License 2.0
6.54k stars 1.17k forks source link

function missing in the params #1807

Closed swizardlv closed 7 years ago

swizardlv commented 7 years ago

Environment details:

Steps to reproduce the issue:

  1. pass the params to openwisk as
    const uuid = require("node-uuid");
    const params = Object.assign({}, {
    actionName: "testIngest"
    }, {
    blocking: true,
    params: {
        "abc":"def",
        "uuid":uuid
    }
    });
    console.log(params);
    openWhisk.actions.invoke(params)
  2. in the openwhisk,
    function main(params) {
    return { "message": "you sent me " + JSON.stringify(params) };
    }

Provide the expected results and outputs:

you sent me {"abc":"def", "uuid": xxxxxxxx}

Provide the actual results and outputs:

you sent me {"abc":"def"}

Additional information you deem important:

rabbah commented 7 years ago
> node
> const uuid = require("node-uuid");
undefined
> JSON.stringify({x:uuid})
'{}'

Are you meaning to get a new uuid and pass that to openwhisk as a parameter rather than passing the uuid object itself anyway? Undefined/functions are not serialized anyway.

rabbah commented 7 years ago

Try this instead:

JSON.stringify({x:uuid.v1()})
'{"x":"98bf0460-e9d5-11e6-84e9-736ec63b0367"}'
swizardlv commented 7 years ago

@rabbah i want to pass some functions to openwhisk (maybe some rest call with credentials). in the action of openwhisk it can be called with some parameters.

is that possible?

rabbah commented 7 years ago

Parameters passed between actions are json objects - you have to serialize values otherwise it will be work. You can send a function as a string and eval it in some other action to run it.

rabbah commented 7 years ago

Closing as invalid (if you want to pass a function, you can serialize it to string and eval it later).