fix: duplicate automation definition for pydantic model

This commit is contained in:
Ida Dittrich 2026-03-09 10:31:02 +01:00
parent 13322e7cf8
commit d59c6c8576

View file

@ -791,20 +791,23 @@ class AutomationObjects:
if not self.checkRbacPermission(AutomationDefinition, "create"):
raise PermissionError("No permission to create definitions")
# getAutomationDefinition returns Pydantic model; convert to dict for .get() access
existing_data = existing.model_dump() if hasattr(existing, "model_dump") else existing
# Build duplicate data
duplicateData = {
"id": str(uuid.uuid4()),
"mandateId": existing.get("mandateId"),
"featureInstanceId": existing.get("featureInstanceId"),
"label": f"{existing.get('label', '')} (Kopie)",
"schedule": existing.get("schedule", ""),
"template": existing.get("template", ""),
"placeholders": existing.get("placeholders", {}),
"mandateId": existing_data.get("mandateId"),
"featureInstanceId": existing_data.get("featureInstanceId"),
"label": f"{existing_data.get('label', '')} (Kopie)",
"schedule": existing_data.get("schedule", ""),
"template": existing_data.get("template", ""),
"placeholders": existing_data.get("placeholders", {}),
"active": False,
"eventId": None,
"status": None,
"executionLogs": [],
"allowedProviders": existing.get("allowedProviders", []),
"allowedProviders": existing_data.get("allowedProviders", []),
}
# Ensure database connector has correct userId context