Skip to content

Commit

Permalink
Ignore corrupted source data (microsoft#4291)
Browse files Browse the repository at this point in the history
Rather than a failure here, we will treat corrupt source data as simply
empty. The only recourse the user currently has is to delete it anyway,
and COM callers have no means to mitigate it.
  • Loading branch information
JohnMcPMS authored and ryfu-msft committed Mar 25, 2024
1 parent 577d8fe commit 0dec5f0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/AppInstallerCLITests/Sources.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -312,14 +312,14 @@ TEST_CASE("RepoSources_InvalidYAML", "[sources]")
{
SetSetting(Stream::UserSources, "Name: Value : BAD");

REQUIRE_THROWS_HR(GetSources(), APPINSTALLER_CLI_ERROR_SOURCES_INVALID);
REQUIRE_NOTHROW(GetSources());
}

TEST_CASE("RepoSources_MissingField", "[sources]")
{
SetSetting(Stream::UserSources, s_SingleSource_MissingArg);

REQUIRE_THROWS_HR(GetSources(), APPINSTALLER_CLI_ERROR_SOURCES_INVALID);
REQUIRE_NOTHROW(GetSources());
}

TEST_CASE("RepoSources_AddSource", "[sources]")
Expand Down Expand Up @@ -1300,4 +1300,4 @@ TEST_CASE("RepoSources_BuiltInDesktopFrameworkSourceAlwaysCreatable", "[sources]
{
Source source(WellKnownSource::DesktopFrameworks);
REQUIRE(source);
}
}
5 changes: 4 additions & 1 deletion src/AppInstallerRepositoryCore/SourceList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,10 @@ namespace AppInstaller::Repository
else
{
std::vector<SourceDetailsInternal> result;
THROW_HR_IF(APPINSTALLER_CLI_ERROR_SOURCES_INVALID, !TryReadSourceDetails(setting.GetName(), *sourcesStream, rootName, parse, result));
if (!TryReadSourceDetails(setting.GetName(), *sourcesStream, rootName, parse, result))
{
AICLI_LOG(YAML, Error, << "Ignoring corrupted source data.");
}
return result;
}
}
Expand Down

0 comments on commit 0dec5f0

Please sign in to comment.