-
Notifications
You must be signed in to change notification settings - Fork 47
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
rest streaming JSON response error #1377
Comments
Hey @noahdietz! I did some digging with this and was able to replicate Dan's results in node (notes on the mirrored buganizer bug) but I have a feeling that what's causing this is some code in genrest. Any tips on how to resolve this? My golang is meh and so is my REST fallback abilities so I think I've made it as far as I can independently tracing this and confirming that it is a consistent issue. Happy to gvc cc @vchudnov-g if you feel like reassigning this to yourself - also an option! |
I'm going to bump this up to p1 because it's a blocker for both me and Dan at this point. I am happy to GVC to pair on it though and am ultimately excited to learn more about the root cause so I can be more helpful digging into these issues in the future!! |
I've started looking at this. To be honest, I'm kind of skeptical that our current implementation of REST server streaming will actually work the way we want it to (exactly the same as gRPC) for this specific testing scenario. Let me explain. In gRPC server streaming, the client Contrast that with how Go's HTTP 1.1 lib (and HTTP 1.1 in general) works, if The We might be able to look at using HTTP 1.1 Trailer Headers to report an error status after the fact and mimic the behavior in client libraries, but this is an update to our REGAPIC server streaming impl (meaning we'd need to verify that Google HTTP apis do this and update clients to standardize regapic impl on that). Here is an example of a server doing it in Go: https://pkg.go.dev/net/http#example-ResponseWriter-Trailers I'm not sure if @vchudnov-g already accounted for/looked into this or not. TBF |
So I think if I understand properly there are two problems here:
Ideally they should both be fixed, but at least from my perspective, issue 2 seems like something we can work around if needed |
The way I understood it, issue 2 happens because of issue 1 and when it's sending that error. I have some thoughts about issue 2 that I shared on the internal bug - PTAL! |
I'm not so sure, at least not without compromising the regapic server-stream logic in our clients. HTTP 1.1 requires that a status code be sent back in the initial response, we cannot write a chunk of data to the response until the response code has been sent. There is a mechanism for when the client is actively/about to send(ing) a massive request payload and it wants confirmation from the backend to continue via the Expect header. This basically has the server send back I think we need to see what Google infra is doing for this case e.g. talk to ESF folks, and I was hoping @vchudnov-g had either already done so during initial regapic designs or had a contact. |
Hi folks. Apologies for being late to the party; I had my hands full with other stuff the past week. I was reading over this conversation, and I think I mostly understand what's been discussed. I just looked at our REGAPIC streaming design docs and they did not go into much detail on errors. So my understanding at the moment is this:
I'm also going to add an internal note about an implementation detail we may be able to use. |
I'll work on issue 1 in #1378 |
I'll reassign this issue to myself to do the workaround discussed on chat and internally |
The gapic showcase tests added in this python PR uncovered an issue with the gapic showcase server. It seems that when using the StreamingSequence server in rest mode, if you request partial data before raising an error, it results in a broken JSON response
Reproduction
In a separate terminal:
we get:
we'd expect something like:
Speculation
Looking though the showcase server code, it looks like stream.send and ReportGRPCError are relevant. They seem to be using different methods to write to the same buffer. Maybe we need to change the flushing strategy?
The text was updated successfully, but these errors were encountered: