From 1649591d7579de14912f14d7041af0e482f2f38f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Tue, 28 Aug 2018 17:45:44 +0200 Subject: [PATCH] Create a copy in the validator's self.document This ensures that further modifications (like setting '_etag' etc.) aren't done in-place. --- pillar/api/custom_field_validation.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pillar/api/custom_field_validation.py b/pillar/api/custom_field_validation.py index 5e08425d..0cd578bc 100644 --- a/pillar/api/custom_field_validation.py +++ b/pillar/api/custom_field_validation.py @@ -1,3 +1,4 @@ +import copy from datetime import datetime import logging @@ -24,8 +25,9 @@ class ValidateCustomFields(Validator): result = super().validate(document, *args, **kwargs) # Store the in-place modified document as self.document, so that Eve's post_internal - # can actually pick it up as the validated document. - self.document = document + # can actually pick it up as the validated document. We need to make a copy so that + # further modifications (like setting '_etag' etc.) aren't done in-place. + self.document = copy.deepcopy(document) return result