From 14c71cf16b3227f632527c4a2e9762a513e0c29f Mon Sep 17 00:00:00 2001 From: Landon Shumway Date: Mon, 29 Dec 2025 12:00:32 -0700 Subject: [PATCH] Set compatible format for duplicate SSN error message --- .../provider-data-v1/handlers/bulk_upload.py | 15 +++++++++++---- .../function/test_handlers/test_bulk_upload.py | 8 +++----- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/backend/compact-connect/lambdas/python/provider-data-v1/handlers/bulk_upload.py b/backend/compact-connect/lambdas/python/provider-data-v1/handlers/bulk_upload.py index 81284a585..e908a73ed 100644 --- a/backend/compact-connect/lambdas/python/provider-data-v1/handlers/bulk_upload.py +++ b/backend/compact-connect/lambdas/python/provider-data-v1/handlers/bulk_upload.py @@ -6,6 +6,8 @@ from aws_lambda_powertools.utilities.typing import LambdaContext from botocore.exceptions import ClientError from botocore.response import StreamingBody +from marshmallow.exceptions import SCHEMA + from cc_common.config import config, logger from cc_common.data_model.schema.license.api import ( LicensePostRequestSchema, @@ -164,11 +166,16 @@ def process_bulk_upload_file( if duplicate_ssn_check_flag_enabled: matched_ssn_index = ssns_in_file_upload.get(ssn_key) if matched_ssn_index: + # format the validation error as dict so it can be processed by email handler downstream raise ValidationError( - message=f'Duplicate License SSN detected for license type ' - f'{validated_license["licenseType"]}. SSN matches with record ' - f'{matched_ssn_index}. Every record must have a unique SSN per license type ' - f'within the same file.' + { + SCHEMA: [ + f'Duplicate License SSN detected for license type ' + f'{validated_license["licenseType"]}. SSN matches with record ' + f'{matched_ssn_index}. Every record must have a unique SSN per license type ' + f'within the same file.' + ] + } ) ssns_in_file_upload.update({ssn_key: i + 1}) except TypeError as e: diff --git a/backend/compact-connect/lambdas/python/provider-data-v1/tests/function/test_handlers/test_bulk_upload.py b/backend/compact-connect/lambdas/python/provider-data-v1/tests/function/test_handlers/test_bulk_upload.py index 4103dcf15..1d6dc5f9c 100644 --- a/backend/compact-connect/lambdas/python/provider-data-v1/tests/function/test_handlers/test_bulk_upload.py +++ b/backend/compact-connect/lambdas/python/provider-data-v1/tests/function/test_handlers/test_bulk_upload.py @@ -342,11 +342,9 @@ def test_bulk_upload_prevents_repeated_ssns_within_the_same_file_upload(self): 'dateOfRenewal': '2025-01-01', 'dateOfExpiration': '2026-01-01', }, - 'errors': [ - 'Duplicate License SSN detected for license type audiologist. SSN matches with record 1. ' - 'Every record must have a unique SSN per license type within the same file.' - ], - } + "errors": {"_schema": ["Duplicate License SSN detected for license type audiologist. " + "SSN matches with record 1. Every record must have a unique SSN per" + " license type within the same file."]}} ), 'EventBusName': 'license-data-events', }