Environment details:
- local deployment (standalone openwhisk)
Steps to reproduce the issue:
- create a web action using this function:
> cat t.js
const main = () => ({
"body": {
"message": "hello"
},
"statusCode": 442
})
- invoke the web action
> wsk action update t t.js --web true
> curl -X POST `wsk action get t --url`
{
"code": "b86c3c15bed0763357caa327bd2f25e4",
"error": "Response is not valid 'message/http'."
}
Expecting the API to work (return the message) but it does not.
Change the statusCode to 400 and the API works as expected.
The relevant logic is here
|
val code = fields.get(rp.statusCode).map { |
|
case JsNumber(c) => |
|
// the following throws an exception if the code is not a whole number or a valid code |
|
StatusCode.int2StatusCode(c.toIntExact) |
|
case JsString(c) => |
|
// parse the string to an Int (not a BigInt) matching JsNumber case match above |
|
// c.toInt could throw an exception if the string isn't an integer |
|
StatusCode.int2StatusCode(c.toInt) |
|
|
|
case _ => throw new Throwable("Illegal status code") |
|
} |
This is an error in the controller for status code 442 but it is swallowed. Amending the Try logic to show the exceptions produces:
exception in resultAsHttp: java.lang.RuntimeException:
Non-standard status codes cannot be created by implicit conversion.
Use `StatusCodes.custom` instead.
For reference, this is the cited message:
https://github.com/akka/akka-http/blob/5f8fb8c29285dcef16d74704394a7f6acf4f544e/akka-http-core/src/main/scala/akka/http/scaladsl/model/StatusCode.scala#L87
Environment details:
Steps to reproduce the issue:
Expecting the API to work (return the
message) but it does not.Change the
statusCodeto 400 and the API works as expected.The relevant logic is here
openwhisk/core/controller/src/main/scala/org/apache/openwhisk/core/controller/WebActions.scala
Lines 251 to 261 in 59b67fe
This is an error in the controller for status code 442 but it is swallowed. Amending the
Trylogic to show the exceptions produces:For reference, this is the cited message:
https://github.com/akka/akka-http/blob/5f8fb8c29285dcef16d74704394a7f6acf4f544e/akka-http-core/src/main/scala/akka/http/scaladsl/model/StatusCode.scala#L87