Skip to content

Conversation

@arslanashraf7
Copy link
Contributor

@arslanashraf7 arslanashraf7 commented Nov 19, 2025

What are the relevant tickets?

https://github.com/mitodl/hq/issues/8853

Description (What does it do?)

Screenshots (if appropriate):

  • Desktop screenshots
  • Mobile width screenshots

How can this be tested?

Pre-Reqs

Testing Steps

  • You need to create a scenario where a user is stuck in a duplicate email error, and you can create that scenario by creating a user manually in edX or see testing steps in feat: Add LTI utilities app (Bad user fix) open-edx-plugins#652
  • It would be ideal to create multiple users in Open edX with email IDs that you will need to use in MITx Online registration as well:
    • A user that was created via Canvas in Open edX
    • Another user that was created manually in open edX
  • Try registering your user in MITx Online with the same emails as you used in the above steps
  • Notice that the user that you created in edX via Canvas should automatically get fixed, and the enrollment should start working, a proper social auth should be present in edX social auth entries for this user, and the sync should be successful overall. Also, check that the old user that you created via LTI gets their email changed to something@lti_example.com and the user is moved to the retirement pipeline. The previous social auth entry should be deleted if existed
  • Notice that the other user that you created without an LTI user stays in the same dup-email error state

Additional Context

This is part of a Multi PR fix and you will need to set up all three to test this end-to-end with mitodl/open-edx-plugins#652, mitodl/edx-api-client#133

@github-actions
Copy link

github-actions bot commented Nov 19, 2025

OpenAPI Changes

Show/hide ## Changes for v0.yaml:
## Changes for v0.yaml:


## Changes for v1.yaml:


## Changes for v2.yaml:


Unexpected changes? Ensure your branch is up-to-date with main (consider rebasing).

@arslanashraf7 arslanashraf7 force-pushed the arslan/88530-fix-lti-based-users branch 3 times, most recently from 04f78d7 to bbb9f0c Compare November 20, 2025 08:04
@arslanashraf7 arslanashraf7 marked this pull request as ready for review November 20, 2025 16:35
@arslanashraf7 arslanashraf7 force-pushed the arslan/88530-fix-lti-based-users branch 2 times, most recently from 0cae285 to 4dabaaf Compare November 20, 2025 16:48
drf-extensions = "^0.8.0"
drf-spectacular = "^0.28.0"
edx-api-client = "^1.13.0"
edx-api-client = { git = "https://github.com/mitodl/edx-api-client", branch = "arslan/8853-fix-lti-dup-users" }
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This will be replaced by an actual pin once mitodl/edx-api-client#133 is merged and released.

Copy link
Collaborator

@rhysyngsun rhysyngsun left a comment

Choose a reason for hiding this comment

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

One comment on the order of operations

openedx/api.py Outdated
else:

# Only try for LTI user duplicate email error fix if the response error was duplicate-email
if _is_duplicate_email_error(resp, data):
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this should go earlier before the username collision handling so we can ideally still try to use the original username

openedx/api.py Outdated
)
# If the LTI API fixed the duplicate email issue, Retry account creation
if dup_email_fix_resp.status_code == status.HTTP_200_OK:
continue
Copy link
Collaborator

Choose a reason for hiding this comment

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

This has the potential to loop infinitely if the API responds with a 200 response but for some reason the next request still fails with the same error, we should set a flag here that we're retrying and if we hit this block again it should stop trying to create the user.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This and the operation order change have been incorporated in 4152ba6.

Copy link
Collaborator

@rhysyngsun rhysyngsun left a comment

Choose a reason for hiding this comment

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

Unable to run this locally due to this error with the dependency definition:

40.49   - Installing edx-api-client (1.13.0 624c7fe)
41.37
41.37     | Failed to clone https://github.com/mitodl/edx-api-client at '624c7fe864d7f2df487ef6a0d670881ead44e113', verify ref exists on remote.
41.37     |
41.37     | Note: This error arises from interacting with the specified vcs source and is likely not a Poetry issue.
41.37     | This issue could be caused by any of the following;
41.37     |
41.37     | - there are network issues in this environment
41.37     | - the revision (624c7fe864d7f2df487ef6a0d670881ead44e113) you have specified
41.37     |     - was misspelled
41.37     |     - is invalid (must be a sha or symref)
41.37     |     - is not present on remote
41.37     |
41.37     | You can also run your poetry command with -v to see more information.

I tried running poetry lock which usually fixes this kind of thing. I see that the github actions python tests are hitting it too so it's not just my environment.

@arslanashraf7 arslanashraf7 force-pushed the arslan/88530-fix-lti-based-users branch 3 times, most recently from 3231441 to b75efd1 Compare November 21, 2025 08:51
@arslanashraf7 arslanashraf7 force-pushed the arslan/88530-fix-lti-based-users branch from b75efd1 to 4152ba6 Compare November 21, 2025 10:00
@arslanashraf7
Copy link
Contributor Author

Unable to run this locally due to this error with the dependency definition:

I tried running poetry lock which usually fixes this kind of thing. I see that the github actions python tests are hitting it too so it's not just my environment.

I squashed commits in mitodl/edx-api-client#133 and the commit id mismatched, This should be fixed as well.

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.

3 participants