-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
feat: expose invalid argument error to clients in bidirectional streaming (#4795) #4819
feat: expose invalid argument error to clients in bidirectional streaming (#4795) #4819
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like there's a Bazel failure and a test failure
Hi @johanbrandhorst , I'm having some trouble running the integration tests following the instructions. I'm not really familiar with gulp and having issue trying to run the gulp CLI commands
would you be able to help? |
I'm... also not much of an expert unfortunately. I usually just let CI run the browser test suite 😬. It looks like the node tests passed in CI on the latest push. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the updates, some more questions
do you know if anyone is familiar and could help with setting up the integration tests? (I think the problem is with gulp version. will try again on my own as well) |
It might be easier to run if you use our CI environment docker image as described in CONTRIBUTING.md, but I'm also happy to just trigger the CI run for you. |
I managed to get gulp to work by forcing it to use version 3.9.1 and also forcing the use of node v10. but don't think it helps with running the integration tests. if i just use the docker command like
I get similar errors like
note that I'm running this on the main branch so it's not related to my changes in this PR, which would've run into the same issues |
Please ignore the gulp tests. It looks like there might be a problem with them, but I don't think this PR will change anything. As you can see, the
|
Sorry if I'm misunderstanding the testing structure, but from my perspective, So I would like to debug the test that's failing, but it would be hard without being able to actually run the integration tests properly from my machine. |
All that sounds right, but that doesn't actually require running
Does that work for you? |
go func() { | ||
for err := range reqErrChan { | ||
if err != nil && err != io.EOF { | ||
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it safe to call this function with the shared w
? Is there some way we can avoid doing this concurrently (a defer? or something).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so testing this implementation with my server works fine but I agree there might be more optimal solution.
I'm not sure about the concern around sharing w
, the timing of this invalid argument error and the timing of a stream of valid responses could happen concurrently. I don't see any better indicators for when it's appropriate to send the error the client.
But one thing I noticed is that runtime.HTTPError
modifies the header, which means the header could be modified twice. I'm thinking about writing the error directly using w.Write()
. My thinking is that if the error occurs in the middle of the stream, it makes sense that the original response header stays at 200.
I have been trying to modify the integration test to test it out but I found that the current test set up waits for the entire request body to be written before actually making the http request. I would expect the response collection to start without waiting for the first goroutine of requests writing to complete. Unfortunately I haven't figured out why that isn't the case yet so it's hard to test the scenario of error occurring in the middle of a stream.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's fine if we can't easily test it. I don't think setting the header will matter once we've started writing to the body, since we can't write the header again. Given that, this is probably fine :). Thanks for testing it manually.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey Johan, thanks for approving this, but I still find that using ErrorHandler
might not be ideal. PTAL at #4864. Let's move the discussion over as well
BTW, the vscode dev containers worked like a charm. Shouldn't have fixated on the docker commands and I assumed it would be the same issues with the dev containers. |
References to other Issues or PRs
Fixes #4795
Have you read the Contributing Guidelines?
yes
Brief description of what is fixed or changed
For bidirectional streaming, allows request decoder to alert the clients of invalid requests.
Other comments