Skip to content

Release 1.168.0 - #4009

Merged
odlbot merged 6 commits into
releasefrom
release-candidate
Sep 22, 2026
Merged

odlbot merged 6 commits into
releasefrom
release-candidate

Conversation

@odlbot

@odlbot odlbot commented Sep 22, 2026

Copy link
Copy Markdown
Contributor

James Kachel

Nathan Levesque

Sar

shaidar and others added 6 commits September 21, 2026 08:48
* fix(flexiblepricing): make status read-only on the applicant serializer

FlexiblePriceSerializer (used by the applicant-facing FlexiblePriceViewSet,
IsAuthenticated-only) included `status` as a plain writable field. Since
the checkout discount gate (is_courseware_flexible_price_approved /
determine_courseware_flexible_price_discount) trusts flexible_price.status
directly, a learner could PATCH their own application to status: "approved"
and receive a financial-aid discount without any staff review.

Status changes remain available through the staff-gated
FlexiblePriceAdminViewSet/FlexiblePriceAdminSerializer, which is unaffected.

Fixes GHSA-2pxf-9249-jf4q.

* Make the affected view read only.

Nothing POST/PATCHes to this anyway. Form submission is via the Wagtail form (which is a traditional form post, since people have to fill that out) and the staff-dashboard stuff uses a separate admin-only viewset.

* Added `courseware_object` but reconsidered so removing it. No sense in changing this API's data at this point.

* Fix status code assert on the new test; change status codes to use the constants rather than bare ints

* Remove these viewsets entirely, since nothing really uses them

---------

Co-authored-by: James Kachel <jkachel@mit.edu>
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
Co-authored-by: CP <collinp@mit.edu>
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
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).

Comment thread main/pagination.py
Comment on lines +49 to +55
class Pagination(PageNumberPagination):
"""Paginator class for infinite loading."""

django_paginator_class = CountOptimizedPaginator
page_size = 12
page_size_query_param = "page_size"
max_page_size = 100

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 new shared Pagination class is missing a default ordering attribute, causing non-deterministic pagination results for v1 API endpoints that do not explicitly order their querysets.
Severity: MEDIUM

Suggested Fix

Add a default ordering to the shared Pagination class in main/pagination.py, such as ordering = "-created_on". This will restore the previous behavior and ensure consistent, predictable pagination for all viewsets that use this class without specifying their own ordering.

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: main/pagination.py#L49-L55

Potential issue: The new shared `Pagination` class in `main/pagination.py` omits the
`ordering = "-created_on"` attribute that was present in the old, local pagination
classes it replaced. This attribute served as a fallback ordering mechanism.
Consequently, `ProgramViewSet` and `CourseViewSet` in the v1 API, which do not define an
explicit order for their querysets, will now return paginated results in a
non-deterministic database order. This can lead to inconsistent page results for API
consumers, where items might appear on different pages or be missed entirely between
requests.

Also affects:

  • courses/views/v1/__init__.py:76~82
  • courses/views/v2/__init__.py:81~87

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

@odlbot
odlbot merged commit 75ac526 into release Sep 22, 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.

4 participants