Skip to content

Commit 6d9a08a

Browse files
committed
Add Slack notifications for IATI generation errors in organisation and activity XML processes
1 parent 097c683 commit 6d9a08a

File tree

1 file changed

+7
-3
lines changed
  • ckanext/iati_generator/actions

1 file changed

+7
-3
lines changed

ckanext/iati_generator/actions/iati.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ def iati_generate_organisation_xml(context, data_dict):
179179
required = h.required_organisation_csv_files()
180180
pre = h.validate_required_csv_folder(Path(tmp_dir), required)
181181
if pre:
182+
h.notify_slack_iati_error("organisation", dataset, pre)
182183
# IatiOrganisationMultiCsvConverter will produce an empty organisation.xml file if the input_folder is empty.
183184
# This it not what we want because the file is useless. For activities this validation is handled by the converter.
184185
# We check and return error to be coherent with IatiMultiCsvConverter.
@@ -191,6 +192,7 @@ def iati_generate_organisation_xml(context, data_dict):
191192
if not success:
192193
# Use the CKAN ValidationError formar for errors
193194
validation_errors = {'Organizacion XML errors': converter.latest_errors}
195+
h.notify_slack_iati_error("organisation", dataset, validation_errors)
194196
log.warning("Error when generating the organisation.xml file.")
195197
raise toolkit.ValidationError(
196198
{"error_org_xml": validation_errors}
@@ -291,12 +293,14 @@ def iati_generate_activities_xml(context, data_dict):
291293
required = h.required_activity_csv_files()
292294
pre_check = h.validate_required_csv_folder(Path(tmp_dir), required)
293295
if pre_check:
296+
h.notify_slack_iati_error("activity", dataset, pre_check)
294297
raise toolkit.ValidationError(pre_check)
295298

296299
result = CsvFolderValidator().validate_folder(tmp_dir)
297300

298301
if not result.is_valid:
299302
normalized_errors = process_validation_failures(dataset, result.issues)
303+
h.notify_slack_iati_error("activity", dataset, normalized_errors)
300304
raise toolkit.ValidationError({"error_activity_xml": normalized_errors})
301305

302306
output_path = tmp_dir + "/activity.xml"
@@ -305,9 +309,9 @@ def iati_generate_activities_xml(context, data_dict):
305309

306310
if not success:
307311
log.warning(f"Could not generate activity file for dataset {dataset['name']}")
308-
raise toolkit.ValidationError(
309-
{"error_activity_xml": {'Activity XML errors': converter.latest_errors}}
310-
)
312+
errors = {"error_activity_xml": {'Activity XML errors': converter.latest_errors}}
313+
h.notify_slack_iati_error("activity", dataset, errors)
314+
raise toolkit.ValidationError(errors)
311315

312316
result_resource = upload_or_update_xml_resource(
313317
context,

0 commit comments

Comments
 (0)