apache / apache/openwhisk-cli

How to invoke a web action for .json context extension via wsk command?

Open
#465 6 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
109
Forks
98
PR merge metrics
No merged PRs in 30d

Description

apache/openwhisk#4712 Environment details:

local deployment

## Steps to reproduce the issue:

1. make a simple raw HTTP web action in python
```
def main(args):
val = args['__ow_headers']
print(args)
return { "response": args,
"val": val }
```

2. try to invoke it with wsk command
```
$ wsk action invoke -r cs/jin-test
{
"error": "The action did not return a dictionary."
}
```

3. check out the activation log
```
wsk activation get --last
"logs": [
"2019-12-06T04:11:54.832861208Z stderr: Traceback (most recent call last):",
"2019-12-06T04:11:54.832914474Z stderr: File \"pythonrunner.py\", line 88, in run",
"2019-12-06T04:11:54.832926486Z stderr: exec('fun = %s(param)' % self.mainFn, self.global_context)",
"2019-12-06T04:11:54.832934019Z stderr: File \"\", line 1, in ",
"2019-12-06T04:11:54.832941Z stderr: File \"__main__.py\", line 3, in main",
"2019-12-06T04:11:54.833038393Z stderr: KeyError: '__ow_headers'"
],
```

4. But it works with curl when invoked with .json context extension
```
curl https://frisb.kakao.com/api/v1/web/jin.c/cs/jin-test.json
{
"response": {
"__ow_body": "",
"__ow_headers": {
"accept": "*/*",
"host": "controllers",
"user-agent": "curl/7.54.0",
"x-request-id": "e7e3d9a52c099c6a6e46bce11207d5a4"
},
"__ow_method": "get",
"__ow_path": "",
"__ow_query": ""
},
"val": {
"accept": "*/*",
"host": "controllers",
"user-agent": "curl/7.54.0",
"x-request-id": "e7e3d9a52c099c6a6e46bce11207d5a4"
}
```

## What I want

I'd love to know if there is a way for the wsk command to invoke a web action with context extensions. I learned that the default is .http in the docs and I wonder if there is no way for wsk to invoke an action other context extensions but .http.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.