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

[MSA] Fix loading from previous config #1246

Merged
merged 1 commit into from
May 13, 2022
Merged
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -131,18 +131,21 @@ void PackageSettingsConfig::loadExisting(const std::string& package_path_or_name

for (const std::string& name : config_data_->getRegisteredNames())
{
// Replace old keys with new ones
std::string yaml_key = name;
/* Generally speaking, we use each config's name as the key to read the yaml from
*
* However, for backwards compatibility, we also allow for the three legacy keys, which we translate here.
* If the name is found in BACKWARDS_KEY_LOOKUP and the legacy key is present in the yaml dictionary,
* we load using the legacy key instead.
*/
auto backwards_match = BACKWARDS_KEY_LOOKUP.find(name);
if (backwards_match != BACKWARDS_KEY_LOOKUP.end())
if (backwards_match != BACKWARDS_KEY_LOOKUP.end() && title_node[backwards_match->second].IsDefined())
{
yaml_key = backwards_match->second;
}

if (title_node[yaml_key].IsDefined())
{
config_data_->get(name)->loadPrevious(config_pkg_path_, title_node[yaml_key]);
}
// We load the previous regardless of whether the title_node[yaml_key] is actually defined
config_data_->get(name)->loadPrevious(config_pkg_path_, title_node[yaml_key]);
}
}
catch (YAML::ParserException& e) // Catch errors, translate to runtime_error
Expand Down