-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
decodeData() isn't call when using a direct response #14346
Comments
Just one check before I dig into this, it looks like you didn't have a direct response body configured. Have you tried adding that and seeing if it fixes your problem? At first glance I wouldn't expect decodeData to be called for a headers only response. |
Ah! Let me try that. |
Do you mean encodeData()? I'm confused. |
you == Alyssa or me? I meant decodeData(), per the above log excerpt. But now that you mention this, I actually not sure how adding a body response to DR would trigger decodeData() into running.... |
yeah, I had encode data and decode swapped, sorry, sigh. Let me actually take a look |
Yeah I'm asking you. :) I'm confused about the issue you are reporting. Why would decodeData run here? I wouldn't expect encodeData to run either without a body. |
If it's a POST request and I have a filter running that inspects the body... why would that not run just because it matches a route that is configured to have a direct response? That sounds counter intuitive no? |
Yeah, so to make things clear, |
Ok, maybe not that counter intuitive given the body is going to /dev/null.... Unless you have a filter that's doing inspection stuff (think a WAF). |
We do have a use case... but I am starting to think it might be a bit too contrived and maybe we shouldn't be using DR for it 🤔 |
If you put the buffer filter in front of your filter, decodeData() will run. You may or may not be able to do that in your scenario. |
That's great, let me try that. Thanks! |
Adding the buffer filter did not do make decodeData() run....:
|
Oh hmm, you are right, sorry. The router will respond right away even if the data is buffered. You could potentially buffer the response in your filter if the request is not complete? |
yeah, I think you'd have to subclass the buffer filter, and block the headers from going to the router until the buffer filter got end stream. As soon as the router sees the headers it's all over :-) |
Alright we went with forwarding to a local process that acts as /dev/null for HTTP. Thanks nonetheless! P.S.: an envoy.router filter replacement that acts as /dev/null could be fun/useful... |
We have the following routes config for an Envoy instance meant to act as /dev/null:
Along with the above, we also have a filter that implements decodeHeaders() and decodeData() to analyze the incoming requests. However, we only see decodeHeaders() being called:
Possible options to work around this:
a) Fix the way we handle direct responses to ensure decodeData() is called too (currently it apparently emits an early local response after decodeHeaders() has been called and then stops the filter chain)
b) Add docs stating that if you want to do the above, you should setup another listener with a direct response and use that as the upstream for the first (or some other similar trick, which sounds too convoluted tbh)
Thoughts?
cc: @alyssawilk @mattklein123
Somewhat related to #13737.
The text was updated successfully, but these errors were encountered: