Skip to content
This repository was archived by the owner on Feb 23, 2026. It is now read-only.

Commit 1203fb9

Browse files
MarkDaoustparthea
andauthored
fix: Ignore unknown fields in rest streaming. (#651)
* Ignore unknown fields in rest streaming. If the api adds a new field to a stremaing response, it shouldn't break old clients. We found this in the google.ai.generativelanguage API. Colab forces our clients to use rest, so all our streaming examples broke when the API team rolled out a new field. * format --------- Co-authored-by: Anthonios Partheniou <partheniou@google.com>
1 parent c9e1cbb commit 1203fb9

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

‎google/api_core/rest_streaming.py‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,9 @@ def __next__(self):
118118
def _grab(self):
119119
# Add extra quotes to make json.loads happy.
120120
if issubclass(self._response_message_cls, proto.Message):
121-
return self._response_message_cls.from_json(self._ready_objs.popleft())
121+
return self._response_message_cls.from_json(
122+
self._ready_objs.popleft(), ignore_unknown_fields=True
123+
)
122124
elif issubclass(self._response_message_cls, google.protobuf.message.Message):
123125
return Parse(self._ready_objs.popleft(), self._response_message_cls())
124126
else:

0 commit comments

Comments
 (0)