fix(auth): ensure current_user is never None in BaseInteractor - #2157
fix(auth): ensure current_user is never None in BaseInteractor#2157sentry[bot] wants to merge 1 commit into
Conversation
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! 🚀 New features to boost your workflow:
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2157 +/- ##
=======================================
Coverage 91.63% 91.63%
=======================================
Files 1337 1337
Lines 53262 53262
Branches 1647 1647
=======================================
Hits 48805 48805
Misses 4136 4136
Partials 321 321
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. |
This PR addresses an
AttributeError: 'NoneType' object has no attribute 'is_authenticated'that occurred whenTriggerSyncInteractor.validate()was called during staff impersonation.Root Cause:
In
BaseInteractor.__init__, whenself.current_ownerwas present,self.current_userwas directly assignedself.current_owner.user. If the impersonated owner did not have a linked DjangoUserobject,self.current_owner.userwould beNone, leading toself.current_useralso beingNone. Subsequent calls toself.current_user.is_authenticatedwould then raise theAttributeError.Fix:
Modified
BaseInteractor.__init__to ensure thatself.current_useralways defaults to Django'sAnonymousUser()ifself.current_owner.userisNone. This aligns with Django's standard practice and guarantees thatself.current_useris always an object with anis_authenticatedattribute, preventingNoneTypeerrors in interactors.Legal Boilerplate
Look, I get it. The entity doing business as "Codecov" is owned by Harness, Inc. In 2026 Harness acquired Codecov and as a result Harness is going to need some rights from me in order to utilize my contributions in this PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Harness can use, modify, copy, and redistribute my contributions, under Harness's choice of terms.
Fixes API-EZD
This PR was automatically generated by Sentry. You can adjust this setting at any time.