Skip to content

Commit

Permalink
feat: log request data on license assignment 400
Browse files Browse the repository at this point in the history
  • Loading branch information
pwnage101 committed Aug 27, 2024
1 parent 5e5476c commit b46d148
Showing 1 changed file with 20 additions and 11 deletions.
31 changes: 20 additions & 11 deletions license_manager/apps/api/serializers.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import logging

from django.conf import settings
from django.core.validators import MinLengthValidator
from rest_framework import serializers
Expand Down Expand Up @@ -26,6 +28,9 @@
)


logger = logging.getLogger(__name__)


class SubscriptionPlanRenewalSerializer(serializers.ModelSerializer):
"""
Serializer for the `SubscriptionPlanRenewal` model.
Expand Down Expand Up @@ -684,17 +689,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 serializers.ValidationError:
logger.error("Received invalid input: %s", attrs)
raise


class EnterpriseEnrollmentWithLicenseSubsidyQueryParamsSerializer(serializers.Serializer): # pylint: disable=abstract-method
Expand Down

0 comments on commit b46d148

Please sign in to comment.