diff --git a/src/Access/SettingsProfileElement.h b/src/Access/SettingsProfileElement.h index c9f6936c832..e4be0821407 100644 --- a/src/Access/SettingsProfileElement.h +++ b/src/Access/SettingsProfileElement.h @@ -19,6 +19,10 @@ class AccessControl; struct SettingsProfileElement { std::optional parent_profile; + /// parent_profile_xml_name is set only when users are configured via XML + /// and is used for user-friendly error messages. + std::optional parent_profile_xml_name; + String setting_name; Field value; Field min_value; diff --git a/src/Access/SettingsProfilesCache.cpp b/src/Access/SettingsProfilesCache.cpp index 2a3dedbbd7a..37a544cf051 100644 --- a/src/Access/SettingsProfilesCache.cpp +++ b/src/Access/SettingsProfilesCache.cpp @@ -170,8 +170,15 @@ void SettingsProfilesCache::substituteProfiles( continue; auto profile_it = all_profiles.find(profile_id); - if (profile_it == all_profiles.end()) - continue; + if (profile_it == all_profiles.end()) { + /// If the textual profile name is set, then users are configured via XML. + /// For these users we want to throw an exception when their profile can't + /// be found. Otherwise, these users are super admins. + if (element.parent_profile_xml_name) + throw Exception(ErrorCodes::THERE_IS_NO_PROFILE, "There is no profile '{}' in configuration file", *element.parent_profile_xml_name); + else + continue; + } const auto & profile = profile_it->second; const auto & profile_elements = profile->elements; diff --git a/src/Access/UsersConfigAccessStorage.cpp b/src/Access/UsersConfigAccessStorage.cpp index a6c4388fef8..6a2995f2579 100644 --- a/src/Access/UsersConfigAccessStorage.cpp +++ b/src/Access/UsersConfigAccessStorage.cpp @@ -142,6 +142,7 @@ namespace auto profile_name = config.getString(profile_name_config); SettingsProfileElement profile_element; profile_element.parent_profile = generateID(AccessEntityType::SETTINGS_PROFILE, profile_name); + profile_element.parent_profile_xml_name = profile_name; user->settings.push_back(std::move(profile_element)); } @@ -473,6 +474,7 @@ namespace String parent_profile_name = config.getString(profile_config + "." + key); SettingsProfileElement profile_element; profile_element.parent_profile = generateID(AccessEntityType::SETTINGS_PROFILE, parent_profile_name); + profile_element.parent_profile_xml_name = parent_profile_name; profile->elements.emplace_back(std::move(profile_element)); continue; }