Skip to content

Release 0.138.3#3308

Merged
odlbot merged 4 commits intoreleasefrom
release-candidate
Feb 19, 2026
Merged

Release 0.138.3#3308
odlbot merged 4 commits intoreleasefrom
release-candidate

Conversation

@odlbot
Copy link
Contributor

@odlbot odlbot commented Feb 19, 2026

cp-at-mit

cp-at-mit and others added 4 commits February 19, 2026 13:25
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
@github-actions
Copy link

OpenAPI Changes

Show/hide ## Changes for v0.yaml:
## Changes for v0.yaml:


## Changes for v1.yaml:


## Changes for v2.yaml:


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

)
return successful_enrollments

return successful_enrollments[0] if successful_enrollments else None
Copy link

Choose a reason for hiding this comment

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

Bug: The create() method returns None on enrollment failure, causing an AttributeError and a 500 error in the view layer when serializing the response.
Severity: HIGH

Suggested Fix

Instead of returning None when successful_enrollments is empty, the create() method should raise a serializers.ValidationError with an appropriate error message. This will allow the view to handle the failure gracefully and return a 400 Bad Request response.

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: courses/serializers/v1/courses.py#L190

Potential issue: The `CourseRunEnrollmentSerializer.create()` method returns `None` if
the `successful_enrollments` list is empty, which can happen if an enrollment fails in
the `create_run_enrollments()` function. The `UserEnrollmentsApiViewSet` uses Django
REST Framework's `CreateModelMixin`, which expects a model instance from `create()`.
When it receives `None`, it attempts to serialize it, leading to an `AttributeError`
when accessing attributes on the `None` object. This causes the API to return a 500
error instead of a meaningful error message indicating the enrollment failure.

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

@odlbot odlbot merged commit d0d14f8 into release Feb 19, 2026
13 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.

2 participants