Skip to content

Commit

Permalink
fix: catch additional XLSForm validation errors during deployment (#5419
Browse files Browse the repository at this point in the history
)

### 📣 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
  • Loading branch information
noliveleger authored Jan 14, 2025
1 parent 9189ac9 commit dddd619
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion kpi/serializers/v2/deployment.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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

Expand Down

0 comments on commit dddd619

Please sign in to comment.