-
-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Handle unset http status #19
Comments
Could you please explain some more about your use case with the output of I understand there could be some exceptional(?) cases to set the response code outside of the actual handler but I wonder if we can handle the situation in a different way. e.g. register the status handling middleware after the pop middleware so the status should be correctly placed before the pop checking it. Actually, checking the status code is currently the spec of the function |
To be clear:
Will return http 200 even if you have zero middleware, this is standard behaviour. I'm not wanting to set the response code outside of the actual handler, but not setting a error code explictly defaults the response code to 200. The problem is the db TX middleware not handling this case so the client will see http 200, but the db transaction got rolledback. |
Oh, I see. I don't know why but I was confused that your issue is a matter of a particular condition with your own middleware to set a response code outside the handler. Now I think I got your point, your code relies on the behavior of the I agree that the current behavior of "200 but rolled back" is indeed problematic, so we need to fix something. One tricky point is that this is middleware for the buffalo and the definition of the buffalo's handler is slightly strict than the standard library (even though it works as the same on this issue):
source: https://pkg.go.dev/github.com/gobuffalo/buffalo#Handler I think this middleware's current implementation follows this concept, the user's handler should set the correct response status before returns. I would like to check some more things related to this issue, and will get back. |
Great, thanks. |
Related issue: #25 |
gobuffalo/buffalo#2345 fixed this issue. |
I have a webhook handler that returns
nil
when no errors I don't explicilty set a http status code.Which will return a http status code of 200.
But since the status code is zero at the point when the middleware checks the status code, buffalo-pop will rollback the transaction even tho there was no error.
So you end up with a endpoint that returns 200 and no error but silently rollsback the transaction.
Maybe:
Thanks.
The text was updated successfully, but these errors were encountered: