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

Commit 9e50cd9

Browse files
authored
Merge pull request #2533 from tseaver/2529-pubsub-fix-server-side-timestamp
Use correct 'publishTime' field name for server-set message timestamp.
2 parents ff35105 + b351f36 commit 9e50cd9

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

google/cloud/pubsub/message.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,5 +89,5 @@ def from_api_repr(cls, api_repr):
8989
instance = cls(
9090
data=data, message_id=api_repr['messageId'],
9191
attributes=api_repr.get('attributes'))
92-
instance._service_timestamp = api_repr.get('publishTimestamp')
92+
instance._service_timestamp = api_repr.get('publishTime')
9393
return instance

unit_tests/test_message.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ def test_from_api_repr_no_attributes(self):
9898
api_repr = {
9999
'data': B64_DATA,
100100
'messageId': MESSAGE_ID,
101-
'publishTimestamp': TIMESTAMP,
101+
'publishTime': TIMESTAMP,
102102
}
103103
message = self._getTargetClass().from_api_repr(api_repr)
104104
self.assertEqual(message.data, DATA)
@@ -116,7 +116,7 @@ def test_from_api_repr_w_attributes(self):
116116
api_repr = {
117117
'data': B64_DATA,
118118
'messageId': MESSAGE_ID,
119-
'publishTimestamp': TIMESTAMP,
119+
'publishTime': TIMESTAMP,
120120
'attributes': ATTRS,
121121
}
122122
message = self._getTargetClass().from_api_repr(api_repr)

0 commit comments

Comments
 (0)