Skip to content
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Persistence layers supporting idempotency
"""

import datetime
import hashlib
import json
Expand Down Expand Up @@ -383,9 +384,9 @@ def get_record(self, data: Dict[str, Any]) -> Optional[DataRecord]:

record = self._get_record(idempotency_key=idempotency_key)

self._validate_payload(data_payload=data, stored_data_record=record)
self._save_to_cache(data_record=record)

self._validate_payload(data_payload=data, stored_data_record=record)
return record

@abstractmethod
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,10 +259,10 @@ def _put_record(self, data_record: DataRecord) -> None:
f"expiry_timestamp: {old_data_record.expiry_timestamp}, "
f"and in_progress_expiry_timestamp: {old_data_record.in_progress_expiry_timestamp}",
)
self._save_to_cache(data_record=old_data_record)

try:
self._validate_payload(data_payload=data_record, stored_data_record=old_data_record)
self._save_to_cache(data_record=old_data_record)
except IdempotencyValidationError as idempotency_validation_error:
raise idempotency_validation_error from exc

Expand Down