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 25b42a5
Showing 1 changed file with 18 additions and 11 deletions.
29 changes: 18 additions & 11 deletions license_manager/apps/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
)


logger = logging.getLogger(__name__)


class SubscriptionPlanRenewalSerializer(serializers.ModelSerializer):
"""
Serializer for the `SubscriptionPlanRenewal` model.
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 25b42a5

Please sign in to comment.