Skip to content

Conversation

@taimoor-ahmed-1
Copy link
Contributor

@taimoor-ahmed-1 taimoor-ahmed-1 commented Oct 6, 2025

This PR fixes the Content Serializer class not being able to fetch username of a retired author by adding a author_username property to the Content MySQL model.

close: openedx/frontend-app-discussions#817

This PR fixes the Content Serializer class not being able to fetch username of a retired author by adding a author_username property to the Content MySQL model.
@taimoor-ahmed-1 taimoor-ahmed-1 self-assigned this Oct 6, 2025
@openedx-webhooks
Copy link

Thanks for the pull request, @taimoor-ahmed-1!

This repository is currently maintained by @openedx/wg-maintainers-forums.

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.


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.

@openedx-webhooks openedx-webhooks added the open-source-contribution PR author is not from Axim or 2U label Oct 6, 2025
@github-project-automation github-project-automation bot moved this to Needs Triage in Contributions Oct 6, 2025
@mphilbrick211 mphilbrick211 moved this from Needs Triage to Ready for Review in Contributions Oct 6, 2025
@mphilbrick211 mphilbrick211 requested a review from a team October 6, 2025 21:17
blarghmatey added a commit to mitodl/forum that referenced this pull request Oct 24, 2025
…MySQL migration

This commit fixes the issue where posts from retired users cause the
discussions MFE to crash with 'Missing :learnerUsername param' error
after migrating from MongoDB to MySQL.

Root Cause:
- V1 forum (MongoDB) stores author_username and retired_username as
  separate fields to preserve historical usernames
- V2 migration script was not reading these fields from MongoDB
- MySQL models only derived username from User table at runtime
- When users are retired, their username changes, losing historical data

Changes Made:
1. Added author_username and retired_username fields to Content model
2. Added save() hook to set author_username on content creation
3. Updated to_dict() methods to use stored username with fallbacks
4. Updated migration script to preserve MongoDB username fields
5. Created Django migration to add database columns

Testing:
- Posts from active users work as before
- Posts from retired users now display with correct historical username
- Frontend properly handles retired user indicators
- Re-running migration preserves original usernames

Fixes: openedx/frontend-app-discussions#817
Related: openedx#236
blarghmatey added a commit to mitodl/forum that referenced this pull request Oct 24, 2025
…MySQL migration

This commit fixes the issue where posts from retired users cause the
discussions MFE to crash with 'Missing :learnerUsername param' error
after migrating from MongoDB to MySQL.

Root Cause:
- V1 forum (MongoDB) stores author_username and retired_username as
  separate fields to preserve historical usernames
- V2 migration script was not reading these fields from MongoDB
- MySQL models only derived username from User table at runtime
- When users are retired, their username changes, losing historical data

Changes Made:
1. Added author_username and retired_username fields to Content model
2. Added save() hook to set author_username on content creation
3. Updated to_dict() methods to use stored username with fallbacks
4. Updated migration script to preserve MongoDB username fields
5. Created Django migration to add database columns

Testing:
- Posts from active users work as before
- Posts from retired users now display with correct historical username
- Frontend properly handles retired user indicators
- Re-running migration preserves original usernames

Fixes: openedx/frontend-app-discussions#817
Related: openedx#236
blarghmatey added a commit to mitodl/forum that referenced this pull request Oct 24, 2025
…MySQL migration

This commit fixes the issue where posts from retired users cause the
discussions MFE to crash with 'Missing :learnerUsername param' error
after migrating from MongoDB to MySQL.

Root Cause:
- V1 forum (MongoDB) stores author_username and retired_username as
  separate fields to preserve historical usernames
- V2 migration script was not reading these fields from MongoDB
- MySQL models only derived username from User table at runtime
- When users are retired, their username changes, losing historical data

Changes Made:
1. Added author_username and retired_username fields to Content model
2. Added save() hook to set author_username on content creation
3. Updated to_dict() methods to use stored username with fallbacks
4. Updated migration script to preserve MongoDB username fields
5. Created Django migration to add database columns

Testing:
- Posts from active users work as before
- Posts from retired users now display with correct historical username
- Frontend properly handles retired user indicators
- Re-running migration preserves original usernames

Fixes: openedx/frontend-app-discussions#817
Related: openedx#236
taimoor-ahmed-1 pushed a commit that referenced this pull request Oct 27, 2025
…MySQL migration (#240)

This commit fixes the issue where posts from retired users cause the
discussions MFE to crash with 'Missing :learnerUsername param' error
after migrating from MongoDB to MySQL.

Root Cause:
- V1 forum (MongoDB) stores author_username and retired_username as
  separate fields to preserve historical usernames
- V2 migration script was not reading these fields from MongoDB
- MySQL models only derived username from User table at runtime
- When users are retired, their username changes, losing historical data

Changes Made:
1. Added author_username and retired_username fields to Content model
2. Added save() hook to set author_username on content creation
3. Updated to_dict() methods to use stored username with fallbacks
4. Updated migration script to preserve MongoDB username fields
5. Created Django migration to add database columns

Testing:
- Posts from active users work as before
- Posts from retired users now display with correct historical username
- Frontend properly handles retired user indicators
- Re-running migration preserves original usernames

Fixes: openedx/frontend-app-discussions#817
Related: #236
@mphilbrick211
Copy link

@openedx/wg-maintainers-forums would someone be able to review this for us?

@taimoor-ahmed-1 in the meantime, there's some branch conflicts that have popped up - would you mind resolving?

@taimoor-ahmed-1
Copy link
Contributor Author

@mphilbrick211 closing this PR in favor of #240

@github-project-automation github-project-automation bot moved this from Ready for Review to Done in Contributions Oct 30, 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.

Forums V2 with retired user results in a display error when viewing posts

4 participants