ibm-cloud-docs / openwhisk

Prod repo for IBM Cloud Functions docs
9 stars 36 forks source link

Trigger payload error #183

Closed ccesario closed 4 years ago

ccesario commented 4 years ago

Hi, I would like to report a possible BUG with Functions, specific in Triggers. It seems when Trigger is created by web GUI, the Actions does not load the payload content as expected. But when the trigger is created by IBMCloud CLI, the Action load the Trigger payload content as expected.

Trying debug this, it seems that when the Trigger is created by WEB GUI the payload content is saved escaped, look this

Part of result


 "
  .......
  duration": 359,
    "end": 1585231392939,
    "logs": [],
    "name": "alarm",
    "namespace": "xxxxxxxxxx",
    "publish": false,
    "response": {
        "result": {
            "config": {
                "cron": "*/2 * * * *",
                "name": "TestePHP4",
                "namespace": "xxxxxxxxxxxxx",
                "payload": {
                    "payload": "{ \n    \"message\": \"Odin\"\n}"     < ---------  **This content is wrong**
                }
            },
            "status": {
                "active": true,
                "dateChanged": 1585231383360,
                "dateChangedISO": "2020-03-26T14:03:03Z"
            }

When the Trigger is created by CLI

# ibmcloud fn trigger create TestePHP3 --feed /whisk.system/alarms/alarm --param cron "*/2 * * * *" --param trigger_payload "{\"message\":\"Odin\"}"

 .......
 "duration": 1150,
    "end": 1585231699354,
    "logs": [],
    "name": "alarm",
    "namespace": "xxxxxxxxxxxxx",
    "publish": false,
    "response": {
        "result": {
            "config": {
                "cron": "*/2 * * * *",
                "name": "TestePHP3",
                "namespace": "xxxxxxxxxxx",
                "payload": {
                    "message": "Odin"                    <--------- *This works as expected*
                }
            },
            "status": {
                "active": true,
                "dateChanged": 1585231315286,
                "dateChangedISO": "2020-03-26T14:01:55Z"
            }
        },
        "size": 216,
        "status": "success",
        "success": true
    },
    "start": 1585231698204,
    "subject": "xxxxxxxxxxxxxx",
    "version": "0.0.164"
}
kersten1 commented 4 years ago

Looking into it....

ccesario commented 4 years ago

Hi @kersten1 Do you have any news about it!?

regards,

davetropeano commented 4 years ago

@ccesario do you see the same behavior when you invoke the action directly?

ccesario commented 4 years ago

Hi @davetropeano, No, this issue only happen when I link function to trigger. When I invoke the function manually with correct json params it run as expected.

Regards

ccesario commented 4 years ago

Hi folks, Any news about this!?

regards,

kersten1 commented 4 years ago

@davetropeano - did you find anything out?

ccesario commented 4 years ago

Only to report, this issue still happing, I just tested it today

sandrarapp commented 4 years ago

We've moved the issue to the Functions UI GHE: https://github.ibm.com/BlueMix-Fabric/Bluemix-Whisk-UI/issues/3630.

davetropeano commented 4 years ago

@ccesario we lost a thread here so apologies. Development is looking into this but in parallel last week I tried to duplicate your issue and could not replicate the problem at all.

My guess is that you must have had embedded newlines in your strings. This can easily happen in *nix environments with copy/paste to command line. I had no problem creating a function action with default params and passed in params, then a trigger with default params, then a rule connecting the two. In no case were embedded newlines appearing. I suggest going through https://cloud.ibm.com/docs/openwhisk?topic=cloud-functions-triggers.

ccesario commented 4 years ago

@ccesario we lost a thread here so apologies. Development is looking into this but in parallel last week I tried to duplicate your issue and could not replicate the problem at all.

My guess is that you must have had embedded newlines in your strings. This can easily happen in *nix environments with copy/paste to command line. I had no problem creating a function action with default params and passed in params, then a trigger with default params, then a rule connecting the two. In no case were embedded newlines appearing. I suggest going through https://cloud.ibm.com/docs/openwhisk?topic=cloud-functions-triggers.

Hello @davetropeano, Thanks by your reply.

But I believe that the problem is not by end user side. In my tests, I typed the json content, not copied/paste. And when I saved the Periodic Trigger and ran the query by command line I saw the content that I paste in this ticket. I asked to other user reproduce it in him account and the same result it was generated. Indeed even the user Copy and Paste I believe that server Side would care the code to prevent this kind of issue :)

Lets wait your Development team check it. Best regards

sandrarapp commented 4 years ago

Hi all, I can confirm that there is a difference in how the payload is being saved when creating it from UI vs. CLI as described by @ccesario:

Created via UI:

"payload": {
  "payload": "{ \n    \"message\": \"Odin\"\n}"     < ---------  **This content is wrong**
 }

Created via CLI:

"payload": {
  "message": "Odin"                    <--------- *This works as expected*
}

I think that we should to align this behavior in the UI to be the same as in CLI. We are working on a fix for that problem.

ccesario commented 4 years ago

Hi @sandrarapp, Nice to know that you could reproduce it. if possible, let us know when fixed it.

Regards Carlos

kersten1 commented 4 years ago

@sandrarapp is this issue opened elsewhere so I can close here?

kersten1 commented 4 years ago

Thanks!