Skip to content

Rest streaming partial data issue #2375

Open
@daniel-sanche

Description

@daniel-sanche

Copied from googleapis/gapic-showcase#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

Metadata

Metadata

Assignees

Labels

priority: p3Desirable enhancement or fix. May not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions