jiangpengcheng opened a new issue #51: command `wsk action invoke` fails in some case URL: https://github.com/apache/incubator-openwhisk-client-go/issues/51 when create action using below code: ``` #demo.js function main(params) { return { response: params }; } ``` and then use `wsk action invoke demo --result`, the command will return an error: ``` error: Unable to invoke action 'demo': The connection failed, or timed out. (HTTP status code 200) Run 'wsk --help' for usage. ``` the reason is described below: when wsk get the http result: ``` []byte(`{"response": {}}`) ``` it will check whether the result succeed or failed in line 381 of `incubator-openwhisk-client-go/whisk/client.go` ``` if (IsHttpRespSuccess(resp) && // HTTP Status == 200 data!=nil && // HTTP response body exists v != nil && !strings.Contains(reflect.TypeOf(v).String(), "Activation") && // Request is not `wsk activation get` !IsResponseResultSuccess(data)) { // HTTP response body has Whisk error result Debug(DbgInfo, "Got successful HTTP; but activation response reports an error\n") return parseErrorResponse(resp, data, v) } ``` in `isResponseResultSuccess`, it will try to decode data to a golang struct: ``` func IsResponseResultSuccess(data []byte) bool { errResp := new(WhiskErrorResponse) err := json.Unmarshal(data, &errResp) if (err == nil && errResp.Response != nil) { Debug(DbgWarn, "data is %s", data) return errResp.Response.Success } Debug(DbgWarn, "data is %s", data) Debug(DbgWarn, "IsResponseResultSuccess: failed to parse response result: %v\n", err) return true; } # struct type WhiskResponse struct { Result *WhiskResult `json:"result"` Success bool `json:"success"` Status *interface{} `json:"status"` } type WhiskResult struct { } type WhiskErrorResponse struct { Response *WhiskResponse `json:"response"` } ``` while the `demo` action's result including the `response` key and its corresponding value is a dict, so it will be decoded without error with `err.Resp.Response != nil`, but this dict doesn't has a key named 'success', so the value of `errResp.Response.Success` will be `false`, it lead to the whole command failed.
---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services
