mirror of https://github.com/mamba-org/mamba.git
fix: Skip misformatted configuration files (#3580)
Co-authored-by: Julien Jerphanion <git@jjerphan.xyz> Co-authored-by: Chaoneng Quan <chaonengquan@Chaonengs-MacBook-Pro.local>
This commit is contained in:
parent
a638f702e2
commit
554d9264da
|
@ -2338,6 +2338,14 @@ namespace mamba
|
|||
strStream << inFile.rdbuf();
|
||||
std::string s = strStream.str();
|
||||
config = YAML::Load(expandvars(s));
|
||||
if (config.IsScalar())
|
||||
{
|
||||
LOG_WARNING << fmt::format(
|
||||
"The configuration file at {} is misformatted or corrupted. Skipping file.",
|
||||
file.string()
|
||||
);
|
||||
return YAML::Node();
|
||||
}
|
||||
}
|
||||
catch (const std::exception& ex)
|
||||
{
|
||||
|
|
|
@ -918,6 +918,15 @@ namespace mamba
|
|||
util::unset_env("MAMBA_CHANNEL_PRIORITY");
|
||||
}
|
||||
|
||||
TEST_CASE_FIXTURE(Configuration, "skip_misformatted_config_file")
|
||||
{
|
||||
std::string rc = "invalid_scalar_value";
|
||||
load_test_config(rc);
|
||||
CHECK_EQ(config.sources().size(), 1);
|
||||
CHECK_EQ(config.valid_sources().size(), 0);
|
||||
CHECK_EQ(config.dump(), "");
|
||||
}
|
||||
|
||||
TEST_CASE_FIXTURE(Configuration, "pinned_packages")
|
||||
{
|
||||
std::string rc1 = unindent(R"(
|
||||
|
|
Loading…
Reference in New Issue