diff --git a/sendgrid/helpers/mail/asm.py b/sendgrid/helpers/mail/asm.py index b4889ead2..59e49eee5 100644 --- a/sendgrid/helpers/mail/asm.py +++ b/sendgrid/helpers/mail/asm.py @@ -41,6 +41,8 @@ def groups_to_display(self): @groups_to_display.setter def groups_to_display(self, value): + if value is not None and len(value) > 25: + raise ValueError("New groups_to_display exceeds max length of 25.") self._groups_to_display = value def get(self): diff --git a/test/test_mail.py b/test/test_mail.py index 3356eef52..8b88f5b14 100644 --- a/test/test_mail.py +++ b/test/test_mail.py @@ -468,6 +468,9 @@ def test_unicode_values_in_substitutions_helper(self): json.dumps(expected_result, sort_keys=True) ) + def test_asm_display_group_limit(self): + self.assertRaises(ValueError, ASM, 1, list(range(26))) + def test_disable_tracking(self): tracking_settings = TrackingSettings() tracking_settings.click_tracking = ClickTracking(False, False)