diff --git a/tests/dat/actions/asyncError.js b/tests/dat/actions/asyncError.js new file mode 100644 index 00000000000..e81afa44cbe --- /dev/null +++ b/tests/dat/actions/asyncError.js @@ -0,0 +1,13 @@ +function main(params) { + var str = params.payload; + + return whisk.invoke({ + name: '!', // Invalid action name + parameters: { + payload: str + }, + blocking: true + }).then(function (activation) { + return {}; + }); +} diff --git a/tests/src/system/basic/WskBasicTests.scala b/tests/src/system/basic/WskBasicTests.scala index 24492e96fda..e68524ba5ad 100644 --- a/tests/src/system/basic/WskBasicTests.scala +++ b/tests/src/system/basic/WskBasicTests.scala @@ -295,6 +295,17 @@ class WskBasicTests .stderr should include regex (""""error": "This error thrown on purpose by the action."""") } + it should "create and invoke a blocking action resulting in an error response object" in withAssetCleaner(wskprops) { + (wp, assetHelper) => + val name = "errorResponseObject" + assetHelper.withCleaner(wsk.action, name) { + (action, _) => action.create(name, Some(TestUtils.getTestActionFilename("asyncError.js"))) + } + + wsk.action.invoke(name, blocking = true, expectedExitCode = 246) + .stderr should include regex (""""error": "name '!' contains illegal characters \(.+\)"""") + } + it should "invoke a blocking action and get only the result" in withAssetCleaner(wskprops) { (wp, assetHelper) => val name = "basicInvoke" diff --git a/tools/cli/go-whisk/whisk/client.go b/tools/cli/go-whisk/whisk/client.go index 0b2cff7923b..1b3f8224d09 100644 --- a/tools/cli/go-whisk/whisk/client.go +++ b/tools/cli/go-whisk/whisk/client.go @@ -307,10 +307,10 @@ func parseWhiskErrorResponse(resp *http.Response, data []byte, v interface{}) (* err := json.Unmarshal(data, whiskErrorResponse) // Determine if a whisk.error() response was received. Otherwise, the body contents are unknown (#6) - if err == nil && whiskErrorResponse.Response.Result.Error != nil { - Debug(DbgInfo, "Detected that a whisk.error(\"%s\") was returned\n", *whiskErrorResponse.Response.Result.Error) + if err == nil && whiskErrorResponse.Response.Status != nil { + Debug(DbgInfo, "Detected that a whisk.error(\"%s\") was returned\n", *whiskErrorResponse.Response.Status) errMsg := wski18n.T("The following application error was received: {{.err}}", - map[string]interface{}{"err": *whiskErrorResponse.Response.Result.Error}) + map[string]interface{}{"err": *whiskErrorResponse.Response.Status}) whiskErr := MakeWskError(errors.New(errMsg), resp.StatusCode - 256, NO_DISPLAY_MSG, NO_DISPLAY_USAGE, NO_MSG_DISPLAYED, APPLICATION_ERR) return parseSuccessResponse(resp, data, v), whiskErr @@ -361,13 +361,7 @@ type WhiskErrorResponse struct { } type WhiskErrorResult struct { - Status string `json:"status"` - Success bool `json:"success"` - Result WhiskErrorMessage `json:"result"` -} - -type WhiskErrorMessage struct { - Error *string `json:"error"` + Status *string `json:"status"` } func (r ErrorResponse) Error() string {