Closed beverlycodes closed 5 years ago
@ryanfields we have not observed that behaviour.
Please can you give a clear worked example?
I have tested this on docker swarm on my local with below function code.
"use strict"
module.exports = (event, context) => {
let err;
const result = {
status: "You said: " + JSON.stringify(event.body)
};
if(event.body === "fail" ){
context
.status(400)
.succeed(result);
} else {
context
.status(200)
.succeed(result);
}
}
It is reponsing with correct response codes.
@ryanfields could you please provide a code snippet of your function? We will try to reproduce the same behavior.
With our code snippet, we can see correct response code being returned by the function.
Not an issue.
Setting a status code via context or letting the template itself handle an error both result in a 200 response code being sent to the original invoker. May be a bug in of-watchdog or even further up the chain rather than this template since I originally tried with a custom template and got the same result. I can assert that a non-200 status code is going out, but the original invoker (faas-cli or the faas-netes UI) reports a 200. The error body is sent, it just comes through with a 200 status code instead of 500 or whatever custom code was used.