Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve RuntimeWarning about interacting with database during AppConfig.ready() #2003

Closed
angela-tran opened this issue Apr 9, 2024 · 2 comments · Fixed by #2152
Closed
Assignees
Labels
back-end Django views, sessions, middleware, models, migrations etc. chore Chores and tasks for code cleanup, dev experience, admin/configuration settings, etc.

Comments

@angela-tran
Copy link
Member

Should we be worried about this / look into it further? What can go wrong if "the app registry has not been fully populated" / what does that even mean?

Looking into this a little further, I found some Django docs that correspond with the RuntimeWarning we're seeing. This section warns against interacting with the database in AppConfig.ready():

image

Our OAuthAppConfig interacts with the database by querying for all AuthProviders.

The "Application intialization process" documentation describes how the app registry gets populated and why "premature database queries are discouraged": https://docs.djangoproject.com/en/5.0/ref/applications/#initialization-process

But I'm not sure if there's a better place for us to register our Authlib configurations.

Maybe we should register each AuthProvider's configuration upon the first attempt to actually use it?

Originally posted by @angela-tran in #1809 (comment)

@thekaveman
Copy link
Member

Related: #1379

@thekaveman thekaveman added chore Chores and tasks for code cleanup, dev experience, admin/configuration settings, etc. back-end Django views, sessions, middleware, models, migrations etc. labels Apr 9, 2024
@github-project-automation github-project-automation bot moved this from Todo to Done in Digital Services May 14, 2024
@angela-tran angela-tran reopened this May 14, 2024
@github-project-automation github-project-automation bot moved this from Done to In progress in Digital Services May 14, 2024
@angela-tran
Copy link
Member Author

Exceptions from misconfiguration of AuthProviders could also be swallowed by the way the code works right now, and the fix to this ticket would also fix that

@angela-tran angela-tran moved this from In progress to Todo in Digital Services Jun 4, 2024
@angela-tran angela-tran moved this from Todo to Stretch in Digital Services Jun 4, 2024
@angela-tran angela-tran moved this from Stretch to In progress in Digital Services Jun 10, 2024
@angela-tran angela-tran self-assigned this Jun 10, 2024
@github-project-automation github-project-automation bot moved this from In progress to Done in Digital Services Jun 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
back-end Django views, sessions, middleware, models, migrations etc. chore Chores and tasks for code cleanup, dev experience, admin/configuration settings, etc.
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants