Skip to content

Commit 0c5d24c

Browse files
committed
PYTHON-2181 Raise an informative error including the entire command response when operationTime is missing from aggregate command response
1 parent 914d206 commit 0c5d24c

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

pymongo/change_stream.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,12 @@ def _process_result(self, result, session, server, sock_info, slave_ok):
145145
if (self._start_at_operation_time is None and
146146
self.resume_token is None and
147147
sock_info.max_wire_version >= 7):
148-
self._start_at_operation_time = result["operationTime"]
148+
self._start_at_operation_time = result.get("operationTime")
149+
# PYTHON-2181: informative error on missing operationTime.
150+
if self._start_at_operation_time is None:
151+
raise OperationFailure(
152+
"Expected field 'operationTime' missing from command "
153+
"response : %r" % (result, ))
149154

150155
def _run_aggregation_cmd(self, session, explicit_session):
151156
"""Run the full aggregation pipeline for this ChangeStream and return

0 commit comments

Comments
 (0)