Skip to content

Release 1.165.4 - #3945

Merged
odlbot merged 5 commits into
releasefrom
release-candidate
Sep 10, 2026
Merged

odlbot merged 5 commits into
releasefrom
release-candidate

Conversation

@odlbot

@odlbot odlbot commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

annagav

James Kachel

cp-at-mit

Chris Chudzicki

ChristopherChudzicki and others added 5 commits September 9, 2026 13:54
…3934)

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Chris Chudzicki <christopher.chudzicki@gmail.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
@github-actions

Copy link
Copy Markdown

OpenAPI Changes

Show/hide changes
## Changes for v0.yaml:
No changes detected

## Changes for v1.yaml:
No changes detected

## Changes for v2.yaml:
No changes detected

Unexpected changes? Ensure your branch is up-to-date with main (consider rebasing).


class LineSerializer(serializers.ModelSerializer):
product = serializers.SerializerMethodField()
product = ProductSerializer(read_only=True)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: The ProductPurchasableObjectField.to_representation method does not handle None values, causing a crash when serializing an order line for a deleted product.
Severity: HIGH

Suggested Fix

Add a null check at the beginning of the ProductPurchasableObjectField.to_representation() method. If the input value is None, the method should return None or an empty representation to prevent the InvalidPurchasableObjectTypeError exception.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.

Location: ecommerce/serializers/__init__.py#L422

Potential issue: The `LineSerializer` was changed to use
`ProductSerializer(read_only=True)`. This serializer includes a `purchasable_object`
field handled by `ProductPurchasableObjectField`. If the underlying purchasable object
(e.g., a `CourseRun`) has been deleted from the database, the `GenericForeignKey` for it
will resolve to `None`. The `to_representation` method in
`ProductPurchasableObjectField` does not handle this `None` case. It fails all
`isinstance` checks and raises an `InvalidPurchasableObjectTypeError`. This will cause
API endpoints that serialize order history, such as `/api/v0/orders/history/`, to crash
for any user whose order contains a product associated with a deleted courseware item.

Did we get this right? 👍 / 👎 to inform future reviews.

@odlbot
odlbot merged commit b5d1951 into release Sep 10, 2026
27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants