Skip to content

Commit

Permalink
fix: make nullable django fields also Noneable in event data
Browse files Browse the repository at this point in the history
This should hopefully fix the error we are currently seeing when
attempting to serialize real-life LC fulfillments outside of unit test
environments.  The error is exactly described in this ticket for a
different event experiencing the same issue:

edx/edx-arch-experiments#788

ENT-9213
  • Loading branch information
pwnage101 committed Sep 12, 2024
1 parent eb17e03 commit ff45dd6
Show file tree
Hide file tree
Showing 4 changed files with 137 additions and 101 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ __________



[9.14.1] - 2024-09-12
---------------------

Changed
~~~~~~~

* Fixed event ``LEARNER_CREDIT_COURSE_ENROLLMENT_REVOKED`` so that its serializer can tolerate null nullable fields.

[9.14.0] - 2024-09-12
---------------------

Expand Down
2 changes: 1 addition & 1 deletion openedx_events/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
more information about the project.
"""

__version__ = "9.14.0"
__version__ = "9.14.1"
16 changes: 8 additions & 8 deletions openedx_events/enterprise/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ class EnterpriseCustomerUser:
active = attr.ib(type=bool)
linked = attr.ib(type=bool)
is_relinkable = attr.ib(type=bool)
invite_key = attr.ib(type=UUID)
should_inactivate_other_customers = attr.ib(type=bool)
invite_key = attr.ib(type=UUID, default=None)


@attr.s(frozen=True)
Expand Down Expand Up @@ -154,9 +154,9 @@ class EnterpriseCourseEnrollment:
enterprise_customer_user = attr.ib(type=EnterpriseCustomerUser)
course_id = attr.ib(type=CourseKey)
saved_for_later = attr.ib(type=bool)
source_slug = attr.ib(type=str)
unenrolled = attr.ib(type=bool)
unenrolled_at = attr.ib(type=datetime)
source_slug = attr.ib(type=str, default=None)
unenrolled = attr.ib(type=bool, default=None)
unenrolled_at = attr.ib(type=datetime, default=None)


@attr.s(frozen=True)
Expand All @@ -180,9 +180,9 @@ class BaseEnterpriseFulfillment:
created = attr.ib(type=datetime)
modified = attr.ib(type=datetime)
fulfillment_type = attr.ib(type=str)
enterprise_course_entitlement_uuid = attr.ib(type=UUID)
enterprise_course_enrollment = attr.ib(type=EnterpriseCourseEnrollment)
is_revoked = attr.ib(type=bool)
enterprise_course_entitlement_uuid = attr.ib(type=UUID, default=None)
enterprise_course_enrollment = attr.ib(type=EnterpriseCourseEnrollment, default=None)


@attr.s(frozen=True)
Expand All @@ -197,7 +197,7 @@ class LearnerCreditEnterpriseCourseEnrollment(BaseEnterpriseFulfillment):
transaction_id (UUID): Ledgered transaction UUID to associate with this learner credit fulfillment.
"""

transaction_id = attr.ib(type=UUID)
transaction_id = attr.ib(type=UUID, default=None)


@attr.s(frozen=True)
Expand All @@ -212,4 +212,4 @@ class LicensedEnterpriseCourseEnrollment(BaseEnterpriseFulfillment):
license_uuid (UUID): License UUID to associate with this enterprise license fulfillment.
"""

license_uuid = attr.ib(type=UUID)
license_uuid = attr.ib(type=UUID, default=None)
Original file line number Diff line number Diff line change
Expand Up @@ -25,107 +25,135 @@
"name": "fulfillment_type",
"type": "string"
},
{
"name": "is_revoked",
"type": "boolean"
},
{
"name": "enterprise_course_entitlement_uuid",
"type": "string"
"type": [
"null",
"string"
],
"default": null
},
{
"name": "enterprise_course_enrollment",
"type": {
"name": "EnterpriseCourseEnrollment",
"type": "record",
"fields": [
{
"name": "id",
"type": "long"
},
{
"name": "created",
"type": "string"
},
{
"name": "modified",
"type": "string"
},
{
"name": "enterprise_customer_user",
"type": {
"name": "EnterpriseCustomerUser",
"type": "record",
"fields": [
{
"name": "id",
"type": "long"
},
{
"name": "created",
"type": "string"
},
{
"name": "modified",
"type": "string"
},
{
"name": "enterprise_customer_uuid",
"type": "string"
},
{
"name": "user_id",
"type": "long"
},
{
"name": "active",
"type": "boolean"
},
{
"name": "linked",
"type": "boolean"
},
{
"name": "is_relinkable",
"type": "boolean"
},
{
"name": "invite_key",
"type": "string"
},
{
"name": "should_inactivate_other_customers",
"type": "boolean"
}
]
"type": [
"null",
{
"name": "EnterpriseCourseEnrollment",
"type": "record",
"fields": [
{
"name": "id",
"type": "long"
},
{
"name": "created",
"type": "string"
},
{
"name": "modified",
"type": "string"
},
{
"name": "enterprise_customer_user",
"type": {
"name": "EnterpriseCustomerUser",
"type": "record",
"fields": [
{
"name": "id",
"type": "long"
},
{
"name": "created",
"type": "string"
},
{
"name": "modified",
"type": "string"
},
{
"name": "enterprise_customer_uuid",
"type": "string"
},
{
"name": "user_id",
"type": "long"
},
{
"name": "active",
"type": "boolean"
},
{
"name": "linked",
"type": "boolean"
},
{
"name": "is_relinkable",
"type": "boolean"
},
{
"name": "should_inactivate_other_customers",
"type": "boolean"
},
{
"name": "invite_key",
"type": [
"null",
"string"
],
"default": null
}
]
}
},
{
"name": "course_id",
"type": "string"
},
{
"name": "saved_for_later",
"type": "boolean"
},
{
"name": "source_slug",
"type": [
"null",
"string"
],
"default": null
},
{
"name": "unenrolled",
"type": [
"null",
"boolean"
],
"default": null
},
{
"name": "unenrolled_at",
"type": [
"null",
"string"
],
"default": null
}
},
{
"name": "course_id",
"type": "string"
},
{
"name": "saved_for_later",
"type": "boolean"
},
{
"name": "source_slug",
"type": "string"
},
{
"name": "unenrolled",
"type": "boolean"
},
{
"name": "unenrolled_at",
"type": "string"
}
]
}
},
{
"name": "is_revoked",
"type": "boolean"
]
}
],
"default": null
},
{
"name": "transaction_id",
"type": "string"
"type": [
"null",
"string"
],
"default": null
}
]
}
Expand Down

0 comments on commit ff45dd6

Please sign in to comment.