Skip to content

Conversation

@arslanashraf7
Copy link
Contributor

@arslanashraf7 arslanashraf7 commented Oct 29, 2025

Description

The validation API /api/courses/v1/validation/ fails with a 500 error (See the error logs below) when called with all=True and the FEATURES["CERTIFICATES_HTML_VIEW"]=False. This is a logical error in code that tried to check the len(None).

The pull request changes the default value of certificates=None to certificates=[] to standardize the method output, hence stopping the 500 error on len(certificates)>0.

Useful information to include:

These changes were made in #37047 when we migrated the views to class-based.

  • This change impacts Course Author, Operator roles
  • Which edX user roles will this change impact? Common user roles are "Learner", "Course Author",
    "Developer", and "Operator".

Supporting information

Internal Ticket: https://github.com/mitodl/hq/issues/9027

The validation API throws a 500 error under certain conditions mentioned above.
This is the error log:

TypeError: object of type 'NoneType' has no len()
(5 additional frame(s) were not displayed)
...
  File "cms/djangoapps/contentstore/api/views/utils.py", line 136, in _wrapper_view
    return view(self, request, course_key, *args, **kwargs)
  File "cms/djangoapps/contentstore/api/views/course_validation.py", line 101, in get
    certificates=self._certificates_validation(course)
  File "cms/djangoapps/contentstore/api/views/course_validation.py", line 223, in _certificates_validation
    has_certificate=certificates_enabled and len(certificates) > 0,

Testing instructions

  • Set up a course in the studio with one or more non-audit course modes
  • Set FEATURES["CERTIFICATES_HTML_VIEW"]=False in your environment
  • If not already, enable the Authoring MFE and open the course
  • You should not see the error (See attached screenshot)

Deadline

"None" if there's no rush, or provide a specific date or event (and reason) if there is one.

Other information

Error Screenshot
image

@openedx-webhooks openedx-webhooks added the open-source-contribution PR author is not from Axim or 2U label Oct 29, 2025
@openedx-webhooks
Copy link

Thanks for the pull request, @arslanashraf7!

This repository is currently maintained by @openedx/wg-maintenance-edx-platform.

Once you've gone through the following steps feel free to tag them in a comment and let them know that your changes are ready for engineering review.

🔘 Get product approval

If you haven't already, check this list to see if your contribution needs to go through the product review process.

  • If it does, you'll need to submit a product proposal for your contribution, and have it reviewed by the Product Working Group.
    • This process (including the steps you'll need to take) is documented here.
  • If it doesn't, simply proceed with the next step.
🔘 Provide context

To help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:

  • Dependencies

    This PR must be merged before / after / at the same time as ...

  • Blockers

    This PR is waiting for OEP-1234 to be accepted.

  • Timeline information

    This PR must be merged by XX date because ...

  • Partner information

    This is for a course on edx.org.

  • Supporting documentation
  • Relevant Open edX discussion forum threads
🔘 Get a green build

If one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green.

Details
Where can I find more information?

If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources:

When can I expect my changes to be merged?

Our goal is to get community contributions seen and reviewed as efficiently as possible.

However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:

  • The size and impact of the changes that it introduces
  • The need for product review
  • Maintenance status of the parent repository

💡 As a result it may take up to several weeks or months to complete a review and merge your PR.

@github-project-automation github-project-automation bot moved this to Needs Triage in Contributions Oct 29, 2025
@mphilbrick211 mphilbrick211 moved this from Needs Triage to Ready for Review in Contributions Oct 29, 2025
@mphilbrick211 mphilbrick211 added the needs reviewer assigned PR needs to be (re-)assigned a new reviewer label Oct 29, 2025
@pdpinch
Copy link
Contributor

pdpinch commented Oct 30, 2025

Can we have a test for this change?

@arslanashraf7
Copy link
Contributor Author

Can we have a test for this change?

I couldn't find an existing test that tests this specific method, and since this was a logical error, I skipped it as well. I'll try to add one for this change.

@arslanashraf7 arslanashraf7 force-pushed the arslan/fix-validation-api branch from 829e3ac to a6aeb12 Compare October 30, 2025 10:50
@arslanashraf7 arslanashraf7 force-pushed the arslan/fix-validation-api branch from a6aeb12 to b9d6a8c Compare October 30, 2025 11:26
@arslanashraf7
Copy link
Contributor Author

@pdpinch I've updated an existing test with multiple conditions that should be able to cover this type of error if it happens in the future. This is ready for review again.

Copy link
Contributor

@marslanabdulrauf marslanabdulrauf left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@pdpinch
Copy link
Contributor

pdpinch commented Nov 3, 2025

Does this need to be back-ported to Ulmo, or was the bug it fixes introduced after Ulmo was cut?

@arslanashraf7
Copy link
Contributor Author

arslanashraf7 commented Nov 3, 2025

Does this need to be back-ported to Ulmo, or was the bug it fixes introduced after Ulmo was cut?

It was introduced in 54164a9 ~3mo ago. So, it was definitely there before Ulmo was cut. I guess this will need to be backported to Ulmo.

Copy link
Contributor

@pdpinch pdpinch left a comment

Choose a reason for hiding this comment

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

👍

@pdpinch pdpinch merged commit bbd53a0 into openedx:master Nov 3, 2025
49 checks passed
@openedx-webhooks openedx-webhooks removed the needs reviewer assigned PR needs to be (re-)assigned a new reviewer label Nov 3, 2025
@github-project-automation github-project-automation bot moved this from Ready for Review to Done in Contributions Nov 3, 2025
arslanashraf7 pushed a commit to mitodl/edx-platform that referenced this pull request Nov 4, 2025
arslanashraf7 pushed a commit to mitodl/edx-platform that referenced this pull request Nov 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

open-source-contribution PR author is not from Axim or 2U

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

6 participants