Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/8636.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Catch exceptions during initialization of `password_providers`. Contributed by Nicolai Søborg.
13 changes: 9 additions & 4 deletions synapse/handlers/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,10 +172,15 @@ def __init__(self, hs):
# better way to break the loop
account_handler = ModuleApi(hs, self)

self.password_providers = [
module(config=config, account_handler=account_handler)
for module, config in hs.config.password_providers
]
self.password_providers = []
for module, config in hs.config.password_providers:
try:
self.password_providers.append(
module(config=config, account_handler=account_handler)
)
except Exception as e:
logger.warn("Error while initializing %r: %s", module, e)
Copy link
Member

Choose a reason for hiding this comment

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

This would then be something like:

Suggested change
logger.warn("Error while initializing %r: %s", module, e)
raise ConfigError("Error while initializing %r: %s" % (module, e))

Copy link
Member

Choose a reason for hiding this comment

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

Will this work though since we're past the configuration stage when this gets instantiated?

Copy link
Member

Choose a reason for hiding this comment

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

That is... true. I'm failing to find an example of us failing while starting up outside of database and config sensibly atm :/

raise

logger.info("Extra password_providers: %r", self.password_providers)

Expand Down