Skip to content

'User' object has no attribute 'is_verified' #3459

Closed
@omerfarukabaci

Description

@omerfarukabaci

Environment

SaaS (https://sentry.io/)

Steps to Reproduce

Versions:

  • Django: 4.2.15
  • uwsgi: 2.0.24
  • sentry-sdk: 2.13.0
  • django-otp: 1.5.1
  1. Setup django-otp: https://django-otp-official.readthedocs.io/en/stable/overview.html#installation

  2. Use django_otp.admin.OTPAdminSite as custom admin site.

    # urls.py
    from django_otp.admin import OTPAdminSite
    
    admin_site = OTPAdminSite()
    urlpatterns = [path("admin/, admin_site.urls),]
  3. Enable profiling by setting profiles_sample_rate in sentry_sdk.init.

  4. When the uwsgi server starts, the first request to the admin fails with the error:

    'User' object has no attribute 'is_verified'

  5. If you remove the profiles_sample_rate from sentry_sdk.init, the error goes away.

Expected Result

Profiling should not change the behaviour of middleware so I would expect django_otp.middleware.OTPMiddleware to set the is_verified attribute on the User object successfully.

Actual Result

django_otp.middleware.OTPMiddleware somehow cannot set User.is_verified for the first request in the admin. Consequent calls works fine, but only the initial request to admin fails.

Product Area

Profiling

Link

No response

DSN

No response

Version

No response

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions