gapic-generator-python icon indicating copy to clipboard operation
gapic-generator-python copied to clipboard

Rest streaming partial data issue

Open daniel-sanche opened this issue 9 months ago • 0 comments

Copied from https://github.com/googleapis/gapic-showcase/issues/1377:

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

# start a showcase server
gapic-showcase run

In a separate terminal:

# create a new sequence on the server
gapic-showcase sequence create-streaming-sequence --streaming_sequence.content "once upon a time >there was a" --streaming_sequence.responses '{"status": {"code": 12, "message":"error"}, >"response_index": 5}'

# create a rest attempt
curl -X POST http://localhost:7469/v1beta1/streamingSequences/0:stream -H 'x-goog-request-params: >name=streamingSequences/0' -H 'Content-Type: application/json' -H 'x-goog-api-client: gl-python/3.9.2 >rest/2.28.1 gax/2.11.1 gapic/0.0.0'  -d '{}'

we get:

[{
 "content": "once"
},{
 "content": "upon"
},{
 "content": "a"
},{
 "content": "time{"error":{"code":501,"message":"error","details":[],"Body":"","Header":null,"Errors":null}}"
},{
 "content": "there"
}]

we'd expect something like:

[{
 "content": "once"
},{
 "content": "upon"
},{
 "content": "a"
},{
 "content": "time"
},{
 "content": "there"
},{
 "error":{"code":501,"message":"error","details":[],"Body":"","Header":null,"Errors":null}
}]

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?

This issue is the reason for a skipped showcase test

daniel-sanche avatar Apr 05 '25 00:04 daniel-sanche