From 9e90a4ce856d52d88bf91fd38043580a223f5a4c Mon Sep 17 00:00:00 2001 From: Sergei Maertens Date: Mon, 27 Jan 2025 16:04:51 +0100 Subject: [PATCH] :bug: [#5035] Avoid the total configuration wrapper mutating the first step configuration The total configuration wrapper merges the configuration wrapper of each step into a single object for optimized access to values/ components. It takes the first step and merges the remaining steps into it. However, this had the unintended side-effect of mutating the config of the first step, manifesting in the objects API v1 registration with the json_summary tag which contained extra, unexpected keys in the submission data of the first step. Fixed by making a deep copy first to end up with a different instance that can be safely mutated. --- src/openforms/submissions/models/submission.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/openforms/submissions/models/submission.py b/src/openforms/submissions/models/submission.py index 8592e308c2..1fa6c42d4d 100644 --- a/src/openforms/submissions/models/submission.py +++ b/src/openforms/submissions/models/submission.py @@ -2,6 +2,7 @@ import logging import uuid +from copy import deepcopy from dataclasses import dataclass from typing import TYPE_CHECKING, Any, Mapping @@ -429,9 +430,8 @@ def total_configuration_wrapper(self) -> FormioConfigurationWrapper: if len(form_steps) == 0: return FormioConfigurationWrapper(configuration={}) - wrapper = FormioConfigurationWrapper( - form_steps[0].form_definition.configuration - ) + begin_configuration = deepcopy(form_steps[0].form_definition.configuration) + wrapper = FormioConfigurationWrapper(begin_configuration) for form_step in form_steps[1:]: wrapper += form_step.form_definition.configuration_wrapper self._total_configuration_wrapper = wrapper