fix: strip end slash if any when using a subpath - #36870
Conversation
|
Thanks for the pull request, @holaontiveros! This repository is currently maintained by 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 approvalIf you haven't already, check this list to see if your contribution needs to go through the product review process.
🔘 Provide contextTo 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:
🔘 Get a green buildIf one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green. DetailsWhere 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:
💡 As a result it may take up to several weeks or months to complete a review and merge your PR. |
There was a problem hiding this comment.
Pull Request Overview
This PR ensures that any trailing slash on settings.ACCOUNT_MICROFRONTEND_URL is removed before appending subpaths, preventing double slashes in generated URLs.
- Introduce
rstrip('/')onACCOUNT_MICROFRONTEND_URLin multiple modules - Update email template, verification views, services, and management command to use the trimmed base URL
- Replace direct string concatenations with the trimmed variable
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| openedx/core/djangoapps/notifications/email/utils.py | Trim base URL before building notification_settings_url |
| lms/djangoapps/verify_student/views.py | Trim base URL before constructing reverify_url |
| lms/djangoapps/verify_student/services.py | Trim base URL in get_verify_location |
| lms/djangoapps/verify_student/management/commands/send_verification_expiry_email.py | Trim base URL in expiry email link |
Comments suppressed due to low confidence (5)
openedx/core/djangoapps/notifications/email/utils.py:100
- Variable name 'baseUrl' does not follow Python snake_case conventions; consider renaming it to 'base_url'.
baseUrl = settings.ACCOUNT_MICROFRONTEND_URL.rstrip('/')
lms/djangoapps/verify_student/views.py:1131
- Variable name 'baseUrl' does not follow Python snake_case conventions; consider renaming it to 'base_url'.
baseUrl = settings.ACCOUNT_MICROFRONTEND_URL.rstrip('/')
lms/djangoapps/verify_student/services.py:254
- Variable name 'baseUrl' does not follow Python snake_case conventions; consider renaming it to 'base_url'.
baseUrl = settings.ACCOUNT_MICROFRONTEND_URL.rstrip('/')
lms/djangoapps/verify_student/management/commands/send_verification_expiry_email.py:191
- Variable name 'baseUrl' does not follow Python snake_case conventions; consider renaming it to 'base_url'.
baseUrl = settings.ACCOUNT_MICROFRONTEND_URL.rstrip('/')
lms/djangoapps/verify_student/services.py:255
- New URL construction logic with trimmed base URL should have unit tests covering scenarios when
ACCOUNT_MICROFRONTEND_URLis provided with and without a trailing slash.
location = f'{baseUrl}/id-verification'
| Returns URL for IDV on Account Microfrontend | ||
| """ | ||
| location = f'{settings.ACCOUNT_MICROFRONTEND_URL}/id-verification' | ||
| baseUrl = settings.ACCOUNT_MICROFRONTEND_URL.rstrip('/') |
There was a problem hiding this comment.
[nitpick] The same trailing-slash stripping logic is duplicated across multiple modules; consider extracting this into a shared helper function to improve maintainability.
| baseUrl = settings.ACCOUNT_MICROFRONTEND_URL.rstrip('/') | |
| baseUrl = strip_trailing_slash(settings.ACCOUNT_MICROFRONTEND_URL) |
There was a problem hiding this comment.
I mean yeah but it's way better to address the problem in a more global way that probably doesn't even require using URLs as strings... 🤷♂️
There was a problem hiding this comment.
way better to address the problem in a more global way that probably doesn't even require using URLs as strings
absolutely.
As long as we're handing these as strings, though, copilot's advice seems pretty bad? We all know what .rstrip('/') means, why hide it behind a function?
kdmccormick
left a comment
There was a problem hiding this comment.
Just a request to rename baseUrl. Otherwise, looks great, thanks for the fix and the great PR description.
Lastly-- please remove OEXCOM-126 from the commit message since that (Jira?) ticket isn't available to Open edX developers.
Sure thing, I just had it like that given that it's how I had my local configured, I removed it from the title because I don't think it's on any commit, so I guess that's fine right? Thanks for the review! |
|
@holaontiveros: thank you so much for this! Can you help us with a backport to the release/teak branch? We'd really appreciate it! Thanks |
I'll work on it |
While trying to be enrolled on a verified course, the upgrade process gets to an error screen due to a double slash on the URL that it's added while doing the redirection to the account microfrontend Will be backported to Teak. Part of openedx/wg-build-test-release#468
|
2U Release Notice: This PR has been deployed to the edX staging environment in preparation for a release to production. |
|
2U Release Notice: This PR has been deployed to the edX production environment. |
|
2U Release Notice: This PR has been deployed to the edX staging environment in preparation for a release to production. |
|
2U Release Notice: This PR has been deployed to the edX production environment. |
1 similar comment
|
2U Release Notice: This PR has been deployed to the edX production environment. |
|
2U Release Notice: This PR has been rolled back from the edX production environment. |
|
2U Release Notice: This PR has been deployed to the edX production environment. |
1 similar comment
|
2U Release Notice: This PR has been deployed to the edX production environment. |
…penedx#36898) The api/courseware/course fails for all the verified enrollments if you are not using Account MFE, which means that you probably won't set ACCOUNT_MICROFRONTEND_URL in your settings/configurations. So this PR adds a check safely try to do rstrip. Fixes a bug in openedx#36870
While trying to be enrolled on a verified course, the upgrade process gets to an error screen due to a double slash on the URL that it's added while doing the redirection to the account microfrontend Will be backported to Teak. Part of openedx/wg-build-test-release#468
…penedx#36924) The api/courseware/course fails for all the verified enrollments if you are not using Account MFE, which means that you probably won't set ACCOUNT_MICROFRONTEND_URL in your settings/configurations. So this PR adds a check safely try to do rstrip. Fixes a bug in openedx#36870 Backport of: d6dbc40 (cherry picked from commit b07add0)
…penedx#36924) The api/courseware/course fails for all the verified enrollments if you are not using Account MFE, which means that you probably won't set ACCOUNT_MICROFRONTEND_URL in your settings/configurations. So this PR adds a check safely try to do rstrip. Fixes a bug in openedx#36870 Backport of: d6dbc40
Description
While trying to be enrolled on a verified course, the upgrade process get's to an error screen due to a double slash on the URL that it's added while doing the redirection to the account microfrontend
Screenshot of the error:

Video on how you get to the error:
Screen.Recording.2025-06-06.at.12.50.47.p.m.mov
This happens due to the base URL having an ending slash while also using a slash for the next part of the URL:
(Notice the
//before id-verification)Given that the endslash is required for the base URL to work properly this PR intends to remove the endslash (if any) when also a sub-path it's being used next to it to prevent any issue even if there's slight URL changes later.
Afther this change the redirection works properly:
Screen.Recording.2025-06-06.at.12.48.35.p.m.mov
Supporting information
Fixes: openedx/wg-build-test-release#468
Testing instructions
Assumptions prior to testing:
Steps to test:
If everything is working correctly you should be properly redirect to the account verification screen.
Deadline
None
Other information
Include anything else that will help reviewers and consumers understand the change.