fix(snippetgen): fix client streaming samples#1061
Conversation
There was a problem hiding this comment.
@software-dov 👋 I'm having trouble understanding this error, would you remember what this was written to prevent?
Some streaming method request messages have 2+ required fields (pubsub), so the current snippetgen logic adds two fields to the dictionary. That causes this error to be raised. Are fields expected to be set differently for streaming?
# Request passed to `validate_and_transform_request`
[
{
"field":"subscription",
"value":"projects/{project}/subscriptions/{subscription}"
},
{
"field":"stream_ack_deadline_seconds",
"value":2813
}
]I see two unit tests that raise this error, but I don't see any pre-existing tests showing a valid sample config for a client streaming method.
gapic-generator-python/tests/unit/samplegen/test_samplegen.py
Lines 1353 to 1402 in a8d2b3a
There was a problem hiding this comment.
I really don't remember what was going on here. My guess is that I was mildly incorrect about the actual python method signature convention and I was trying to imply that we only wanted a single request to be put into a list...?
TL;DR: It's probably a bug or at least a misreading of the spec on my part.
|
This is ready for review, PTAL @software-dov @parthea. |
There was a problem hiding this comment.
One simpler alternative is:
requests = iter([requests])I chose the generator over iter() to nudge folks towards generating requests on demand.
Opinions/suggestions on the best way to present client streaming welcome!

Fixes #1014 and unblocks #1043.
NOTE: Some real world APIs expect the first request to pass a config (example) so the generated samples will not work out of the box. This will be addressed when the new sample config language is sorted out.