From 25b42a507f87a4fea4cd803e98d942a8c66ce7ed Mon Sep 17 00:00:00 2001 From: Troy Sankey Date: Tue, 27 Aug 2024 12:39:29 -0700 Subject: [PATCH] feat: log request data on license assignment 400 --- license_manager/apps/api/serializers.py | 29 +++++++++++++++---------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/license_manager/apps/api/serializers.py b/license_manager/apps/api/serializers.py index 2215e073..370d89c4 100644 --- a/license_manager/apps/api/serializers.py +++ b/license_manager/apps/api/serializers.py @@ -26,6 +26,9 @@ ) +logger = logging.getLogger(__name__) + + class SubscriptionPlanRenewalSerializer(serializers.ModelSerializer): """ Serializer for the `SubscriptionPlanRenewal` model. @@ -684,17 +687,21 @@ class Meta: ] def validate(self, attrs): - user_emails = attrs.get('user_emails') - user_sfids = attrs.get('user_sfids') - - if user_sfids: - # if saleforce ids list is present then its length must be equal to number of user emails - if len(user_emails) != len(user_sfids): - raise serializers.ValidationError( - 'Number of Salesforce IDs did not match number of provided user emails.' - ) - - return super().validate(attrs) + try: + user_emails = attrs.get('user_emails') + user_sfids = attrs.get('user_sfids') + + if user_sfids: + # if saleforce ids list is present then its length must be equal to number of user emails + if len(user_emails) != len(user_sfids): + raise serializers.ValidationError( + 'Number of Salesforce IDs did not match number of provided user emails.' + ) + + return super().validate(attrs) + except: + logger.error("Received invalid input: %s", attrs) + raise class EnterpriseEnrollmentWithLicenseSubsidyQueryParamsSerializer(serializers.Serializer): # pylint: disable=abstract-method