diff --git a/lib/galaxy/managers/file_source_instances.py b/lib/galaxy/managers/file_source_instances.py index 976aa25a7bda..06bd738122cc 100644 --- a/lib/galaxy/managers/file_source_instances.py +++ b/lib/galaxy/managers/file_source_instances.py @@ -642,18 +642,24 @@ def template_server_configuration( template = catalog.find_template_by(template_id, template_version) oauth2_configuration = get_oauth2_config_or_none(template) oauth2_scope = None + oauth2_client_pair_obj = None if oauth2_configuration is not None: environment = prepare_environment_from_root(template.environment, self._app_vault, self._app_config) user_details = user.config_template_details() - oauth2_client_pair_obj, oauth2_scope = read_oauth2_info_from_configuration( - template.configuration, user_details, environment - ) + try: + oauth2_client_pair_obj, oauth2_scope = read_oauth2_info_from_configuration( + template.configuration, user_details, environment + ) + except Exception: + log.warning( + "Failed to resolve OAuth2 client credentials for template %s - " + "required environment variables may not be set", + template_id, + ) # most configuration definitions won't include this, the default for the # plugin type is the fallback and the typical case here if oauth2_scope is None: oauth2_scope = oauth2_configuration.scope - else: - oauth2_client_pair_obj = None return TemplateServerConfiguration( oauth2_client_pair=oauth2_client_pair_obj, oauth2_configuration=oauth2_configuration,