From dddd6198cc30b57140fcffa7014e7399c756ab03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olivier=20L=C3=A9ger?= Date: Tue, 14 Jan 2025 14:10:31 -0500 Subject: [PATCH] fix: catch additional XLSForm validation errors during deployment (#5419) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ### 📣 Summary Enhanced error handling to catch more validation errors in XLSForm during deployment. ### 📖 Description Validation error handling for XLSForm deployment has been enhanced to catch a wider range of issues. This prevents the display of a generic 500 error in the deployment modal and instead returns the explicit error message. ### Notes Supersedes #5417, #5411 and #5403 --- kpi/serializers/v2/deployment.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/kpi/serializers/v2/deployment.py b/kpi/serializers/v2/deployment.py index da48c8eef5..c82d755e86 100644 --- a/kpi/serializers/v2/deployment.py +++ b/kpi/serializers/v2/deployment.py @@ -1,5 +1,7 @@ from django.conf import settings from pyxform.errors import PyXFormError +from pyxform.validators.enketo_validate import EnketoValidateError +from pyxform.validators.odk_validate import ODKValidateError from rest_framework import serializers from xlsxwriter.exceptions import DuplicateWorksheetName @@ -36,7 +38,12 @@ def create(self, validated_data): # 'deployed' boolean value try: asset.deploy(backend=backend_id, active=validated_data.get('active', False)) - except (DuplicateWorksheetName, PyXFormError) as e: + except ( + DuplicateWorksheetName, + EnketoValidateError, + PyXFormError, + ODKValidateError, + ) as e: raise serializers.ValidationError({'error': str(e)}) return asset.deployment