Skip to content

Conversation

@Akanshu-2u
Copy link
Contributor

@Akanshu-2u Akanshu-2u commented Jul 24, 2025

Description:

The get_user_if_exists function lacks visibility into authentication failures. We can't debug why "user already exists" errors happen in devstack but not in stage.

Solution:

  • Added comprehensive debugging with new toggle IGNORE_LOGGED_IN_USER_ON_MISMATCH.

  • Added custom attributes to track authentication flow and detect issues:

        - Username mismatches between details and existing users.
        - User lookup success/failure states.
        - Database errors during user retrieval.
    
  • Improved logging with detailed info and warning messages.

  • Removed unnecessary pass statement for cleaner code.

JIRA Ticket:

BOMS-3

Reference PR:

PR

Reference pr for testing legacy get_user_if_exists code with current test_file:

#395

@Akanshu-2u Akanshu-2u requested review from UsamaSadiq and robrap July 24, 2025 14:03
@Akanshu-2u Akanshu-2u changed the title Fix and enhance get_user_if_exists pipeline function with debugging capabilities. fix: enhance get_user_if_exists pipeline function with debugging capabilities Jul 24, 2025
Copy link
Contributor

@robrap robrap left a comment

Choose a reason for hiding this comment

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

I did not review tests yet. I'll review once the code has been updated. Thank you.

@Akanshu-2u Akanshu-2u force-pushed the akanshu/bug-in-third-party-authentication-email-and-name-update branch from 3c50eb5 to 3dca82d Compare July 28, 2025 07:36
@Akanshu-2u Akanshu-2u marked this pull request as ready for review July 28, 2025 12:28
@Akanshu-2u Akanshu-2u requested a review from robrap July 28, 2025 12:32
Copy link
Contributor

@robrap robrap left a comment

Choose a reason for hiding this comment

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

Thanks.

@Akanshu-2u Akanshu-2u requested a review from robrap August 5, 2025 09:59
Copy link
Contributor

@robrap robrap left a comment

Choose a reason for hiding this comment

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

As written, I was having difficulty digesting the different tests and ensuring complete coverage and that each test was doing what we wanted to do. I know you are just exploring ddt for the first time, so no worries. I'm providing some feedback that may be useful to everyone who might use ddt at some point.

@Akanshu-2u Akanshu-2u force-pushed the akanshu/bug-in-third-party-authentication-email-and-name-update branch from c0f875c to 5c1717d Compare August 11, 2025 12:51
@Akanshu-2u Akanshu-2u requested a review from robrap August 12, 2025 12:34
Copy link
Contributor

@robrap robrap left a comment

Choose a reason for hiding this comment

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

I know there are lots of comments here, but it was soooo much easier to digest and understand the tests. Thank you for all the changes. We're almost there.

@robrap
Copy link
Contributor

robrap commented Aug 19, 2025

@Akanshu-2u: I haven't gotten to the review yet. However, can you please add me as a collaborator with write access on your private fork? Thank you!

@Akanshu-2u
Copy link
Contributor Author

@Akanshu-2u: I haven't gotten to the review yet. However, can you please add me as a collaborator with write access on your private fork? Thank you!

Added you as a colaborator for my fork.

@robrap
Copy link
Contributor

robrap commented Aug 21, 2025

@Akanshu-2u: I haven't gotten to the review yet. However, can you please add me as a collaborator with write access on your private fork? Thank you!

Added you as a colaborator for my fork.

@Akanshu-2u: Strange. You added me having write access? I ask because I still do not have permissions to resolve PR comments when I am done reviewing.

Copy link
Contributor

@robrap robrap left a comment

Choose a reason for hiding this comment

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

  • I don't see an internal reviewer approval since my last comments, and I was told it was ready for review.
  • Many of the comments say things were addressed, but I don't see any of the changes or new commits. Again, if an internal reviewer were to have looked at my comments and looked at github, this should have been caught before it gets to me.
  • Lastly, lots of the comments say "Addressed", but some of my comments have no response. When you do commit changes, please ensure that you respond to all of my comments, and that you actually addressed them.
    Thank you.
    FYI: @Akanshu-2u @vgulati-apphelix

Copy link

@jcapphelix jcapphelix left a comment

Choose a reason for hiding this comment

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

I've added a few comments,

if you do go with my suggestions/proposals, you'll need to change few places to get the user like

existing_user = self.user

or

different_user = User.objects.create(**self.details['different_user_details'])

All in all if those changes are implemented, it'll be a bit of extra work on this, but it will improve reading the code and reduce repeating of user creation in each test case.

All those are nits, and are just my thoughts on this.

@robrap @Akanshu-2u

Copy link

@jcapphelix jcapphelix left a comment

Choose a reason for hiding this comment

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

Looks good from my side.

@Akanshu-2u Akanshu-2u requested a review from robrap August 25, 2025 11:47
Copy link
Contributor

@robrap robrap left a comment

Choose a reason for hiding this comment

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

Looks great. One small optional nit. Thank you. Just let me know if you intend to change or skip.

Also, one additional request to ensure we didn't break any of the legacy implementation. Could you copy the new tests into the current code, and make sure they pass. You can delete out all the ddt changes, because there will be no toggle and we just want to test legacy behavior. You will also need to delete test conditions that won't be entered, but leave the other test condition. Delete new observability assertions, etc. The point is to ensure that the newer tests (or at least a simplified version of them) pass against the old code, to ensure that we didn't add a regression into the new code and capture it in a test that is pretending all is well.

Let me know if this needs more clarity. I think all is fine, but I just want to be certain. Thank you.

Copy link
Contributor

@robrap robrap left a comment

Choose a reason for hiding this comment

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

@Akanshu-2u: I added some additional changelog and testing requests. Also see #390 (review) for some testing requests and an optional minor update.

@Akanshu-2u
Copy link
Contributor Author

Looks great. One small optional nit. Thank you. Just let me know if you intend to change or skip.

Also, one additional request to ensure we didn't break any of the legacy implementation. Could you copy the new tests into the current code, and make sure they pass. You can delete out all the ddt changes, because there will be no toggle and we just want to test legacy behavior. You will also need to delete test conditions that won't be entered, but leave the other test condition. Delete new observability assertions, etc. The point is to ensure that the newer tests (or at least a simplified version of them) pass against the old code, to ensure that we didn't add a regression into the new code and capture it in a test that is pretending all is well.

Let me know if this needs more clarity. I think all is fine, but I just want to be certain. Thank you.

Yes, I addressed this suggestion and to be very certain about the tests replicated these with the legacy code. After the tests passed with the legacy code , I went onto create a PR with the modified test file which focus just on testing and not for merging.

Copy link
Contributor

@robrap robrap left a comment

Choose a reason for hiding this comment

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

Minor comment . Thank you. No need for internal review.

@robrap
Copy link
Contributor

robrap commented Aug 27, 2025

@Akanshu-2u: After you address the one comment, please mark all comments resolved, including the latest ones. Thank you.

Co-authored-by: Robert Raposa <rraposa@gmail.com>
@Akanshu-2u Akanshu-2u requested review from robrap and removed request for robrap August 27, 2025 05:21
@Akanshu-2u
Copy link
Contributor Author

Akanshu-2u commented Aug 27, 2025

@idegtiarov The pr is reviewed and approved by @robrap . If you are able to approve, squash and release the library, that would be great. Thank you!

We plan to remove temporary toggles once we've proven this safe

UPDATE: Please see PR description for details.

@Akanshu-2u Akanshu-2u requested a review from idegtiarov August 27, 2025 12:29
@robrap
Copy link
Contributor

robrap commented Aug 27, 2025

@Akanshu-2u: You can edit your comment to remove the duplication of the PR description. It is not needed, because it is all in the description. You could instead have written: "Please see PR description for details.". Thank you.

Copy link
Contributor

@robrap robrap left a comment

Choose a reason for hiding this comment

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

Providing an updated approval as well.

@robrap
Copy link
Contributor

robrap commented Sep 11, 2025

[inform] This PR didn't quite accomplish what we had wished, once we were better able to test. This issue is being closed, and we're working on a different proposal that may logout the current user before starting the login process.

@robrap robrap closed this Sep 11, 2025
@robrap robrap deleted the akanshu/bug-in-third-party-authentication-email-and-name-update branch September 11, 2025 03:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants