SSO/logistration: lazy‑load third_party_auth_context to break import cycle#225
Conversation
There was a problem hiding this comment.
Pull request overview
This PR addresses a circular import affecting enterprise SSO/authn context generation by deferring an import until get_mfe_context() runtime, reducing the chance of partially initialized modules during certain import orders.
Changes:
- Removed the module-level import of
third_party_auth_contextfromenterprise_support.utils. - Added a function-scoped import of
third_party_auth_contextinsideget_mfe_context()to break the circular dependency at import time.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
8d40000 to
9fb01d8
Compare
9fb01d8 to
4a693f4
Compare
pwnage101
left a comment
There was a problem hiding this comment.
Approving to unblock, but I really don't like where this landed.
| return f"{base_url}/{enterprise_customer['slug']}" | ||
|
|
||
|
|
||
| def get_mfe_context(request, redirect_to, tpa_hint=None): |
There was a problem hiding this comment.
I'm really not a fan of #139 introducing a duplicate get_mfe_context definition. Now we just have two identical get_mfe_context functions defined in different modules, independently tested, and each lazily imports modules from functions in each other's module. Very messy.
PR Description
This PR fixes a circular import issue affecting enterprise SSO/authn context generation.
Problem
Root Cause
A top-level cross-module import between enterprise_support.utils and user_authn.views.utils caused Python to initialize partially loaded modules, which can break org-name/SSO context resolution flows.
Fix
Why this is safe
Impact
Testing / Validation
Suggested regression checks:
JIRA
https://2u-internal.atlassian.net/browse/AUT-112