Skip to content

Conversation

@blarghmatey
Copy link
Contributor

Description

This PR fixes the 'Missing :learnerUsername param' error that occurs in the AuthorLabel component when the author field is null, undefined, or the 'anonymous' string.

Problem

The learnerPostsLink component was being created unconditionally during render, which meant generatePath() was called with an invalid author value even when the link wasn't going to be displayed. This caused the router to throw an error.

Solution

Wrapped the learnerPostsLink creation in a useMemo hook that:

  • Checks showUserNameAsLink before calling generatePath()
  • Returns null if the link shouldn't be shown
  • Only creates the Link component when all validation conditions are met

Testing

  • Linting passes
  • The fix ensures generatePath is only called when author is a valid username and all other conditions (linkToProfile, not anonymous, not in-context sidebar) are met

@openedx-webhooks
Copy link

Thanks for the pull request, @blarghmatey!

This repository is currently maintained by @openedx/edx-infinity.

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 30, 2025
@github-project-automation github-project-automation bot moved this to Needs Triage in Contributions Oct 30, 2025
@mphilbrick211 mphilbrick211 moved this from Needs Triage to Waiting on Author in Contributions Nov 4, 2025
@taimoor-ahmed-1
Copy link

@blarghmatey can you fix the tests?

@blarghmatey
Copy link
Contributor Author

@taimoor-ahmed-1 the failing test on this branch appears to be unrelated to my changes and is currently failing on master as well. https://github.com/openedx/frontend-app-discussions/actions/runs/18284320993/job/52055073479

@blarghmatey
Copy link
Contributor Author

I have successfully deployed this branch to our production environment and verified that it fully resolves #817

The issue was not with retired users, though I suspect that it may be due to differences with how the Mongo and MySQL manage pagination?

@taimoor-ahmed-1
Copy link

Can someone from the @openedx/committers-edx-platform-2u-infinity with merge access review this PR?

@sarina
Copy link
Contributor

sarina commented Nov 13, 2025

@brian-smith-tcril or @arbrandes could you take a look at this? It needs to get into the release.

@sarina sarina added release blocker Blocks the upcoming release (fix needed) release testing Affects the upcoming release (attention needed) labels Nov 13, 2025
@brian-smith-tcril
Copy link
Contributor

Couple of notes/questions:

  • Is useMemo needed for the fix? I get the impression that using useMemo is just a general improvement, and the fix is just adding the validation logic. I'm not opposed to updating this to utilize useMemo, but it is adding complexity that wasn't originally there. I'd like to ensure the PR description accurately reflects what part is the fix.
  • CI is failing. Are tests passing when you run them locally?

@blarghmatey
Copy link
Contributor Author

I imagine that useMemo isn't required for the fix to work. The main point is to avoid rendering the links when the attributes are not available to the component.

As far as tests, the failing test is failing from the main branch and is unrelated to this change. If someone wants to fix it on master I'm happy to rebase.

@brian-smith-tcril
Copy link
Contributor

@blarghmatey I merged #775 and CI is passing on master now. I'll be happy to merge this PR after it is rebased.

Wrap learnerPostsLink creation in useMemo with guard to prevent
'Missing :learnerUsername param' error. The generatePath function
was being called unconditionally during render even when the link
wouldn't be displayed, causing errors when author was null, undefined,
or the 'anonymous' string.

The fix ensures generatePath is only called when showUserNameAsLink
is true, which validates that author is a valid username.
@blarghmatey blarghmatey force-pushed the tmacey/fix_learner_posts_link branch from cc79730 to ea85320 Compare November 13, 2025 21:04
@codecov
Copy link

codecov bot commented Nov 13, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.56%. Comparing base (16c49b2) to head (ea85320).
⚠️ Report is 2 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #821   +/-   ##
=======================================
  Coverage   94.56%   94.56%           
=======================================
  Files         164      164           
  Lines        3622     3625    +3     
  Branches      996      992    -4     
=======================================
+ Hits         3425     3428    +3     
  Misses        183      183           
  Partials       14       14           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@brian-smith-tcril brian-smith-tcril merged commit a4826ae into openedx:master Nov 13, 2025
6 checks passed
@github-project-automation github-project-automation bot moved this from Waiting on Author to Done in Contributions Nov 13, 2025
@blarghmatey blarghmatey deleted the tmacey/fix_learner_posts_link branch November 13, 2025 21:12
@brian-smith-tcril
Copy link
Contributor

I went ahead and merged this as it fits with the existing patterns used in this component.

I do think in this scenario we could have avoided the unconditionally running issue by moving learnerPostsLink out of AuthorLabel, so instead of having

const AuthorLabel = ({...}) => {
   [...]
   const learnerPostsLink = (...);
   [...]
   return ([...]);
}

we could have done

const LearnerPostsLink = (...);

const AuthorLabel = ({...}) => {
   [...]
   return ([...]);
}

In that case we would have been able to avoid adding the

    if (!showUserNameAsLink) {
      return null;
    }

check.

@sarina
Copy link
Contributor

sarina commented Nov 14, 2025

@blarghmatey will you be opening up a PR against Ulmo for this fix?

@blarghmatey
Copy link
Contributor Author

@sarina thanks for the prompt. I just opened #830

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 release blocker Blocks the upcoming release (fix needed) release testing Affects the upcoming release (attention needed)

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

5 participants