Skip to content

Commit bbcfea6

Browse files
committed
fix: add an infinite recursion guard to the post model validator
The unsetting of fields leads to a retrigger of the model validation, where the sync logic ends up in an infinite recursion. Add a flag so that it runs only once and prevents reentry.
1 parent de9927d commit bbcfea6

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

src/ted_sws/core/model/transform.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,12 @@ def sync_legacy_and_mssdk_fields(self) -> 'MappingPackage':
191191
192192
This ensures the model works with both old code using legacy fields
193193
and new code using MSSDK v2 structure.
194+
Prevents infinite recursion by using a private _sync_done flag.
194195
"""
196+
if getattr(self, "_sync_done", False):
197+
return self
198+
setattr(self, "_sync_done", True)
199+
195200
# If MSSDK v2 fields are missing but legacy fields exist, populate from legacy
196201
# FIXME: this is a transitional solution for code where the legacy file system package parsing is done
197202
if self.metadata is None:

0 commit comments

Comments
 (0)