Skip to content

Release 1.144.3#3447

Merged
odlbot merged 5 commits into
releasefrom
release-candidate
Apr 1, 2026
Merged

Release 1.144.3#3447
odlbot merged 5 commits into
releasefrom
release-candidate

Conversation

@odlbot
Copy link
Copy Markdown
Contributor

@odlbot odlbot commented Mar 31, 2026

James Kachel

Asad Ali

@github-actions
Copy link
Copy Markdown

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).

Comment on lines 173 to +177

return (
instance.first_unexpired_run is not None
and instance.first_unexpired_run.certificate_available_date is not None
and hasattr(instance, "verified_courserun_count")
and instance.verified_courserun_count > 0
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Bug: The get_certificate_available method relies on the verified_courserun_count annotation, which is not present when CourseSerializer is used outside the CourseViewSet, causing incorrect results.
Severity: MEDIUM

Suggested Fix

The logic for get_certificate_available should not depend on an annotation that is only applied in a specific viewset. Instead, it should directly query the related courseruns to determine if any have a verified enrollment mode. This will make the serializer's logic self-contained and reliable across all its usage contexts.

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/v2/courses.py#L173-L177

Potential issue: The `get_certificate_available` method in `CourseSerializer` was
updated to check for a `verified_courserun_count` attribute on the `Course` instance.
This attribute is only annotated onto the queryset within the `CourseViewSet`. However,
`CourseSerializer` is also instantiated directly in other parts of the codebase, such as
in `cms/models.py`. In these contexts, the `Course` instance lacks the
`verified_courserun_count` annotation. The `hasattr` check will fail, causing the method
to silently and incorrectly return `False` for `certificate_available`, leading to
incorrect data in API endpoints that consume the serializer outside the viewset.

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

@odlbot odlbot merged commit 5b1157e into release Apr 1, 2026
12 of 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.

3 participants