Skip to content

Commit

Permalink
Handle empty and flat out invalid files better
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnMcPMS committed Aug 11, 2020
1 parent 53d1ce4 commit 7afa8a5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/AppInstallerCommonCore/Public/AppInstallerErrors.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
#define APPINSTALLER_CLI_ERROR_LIBYAML_ERROR ((HRESULT)0x8A150027)
#define APPINSTALLER_CLI_ERROR_MANIFEST_VALIDATION_WARNING ((HRESULT)0x8A150028)
#define APPINSTALLER_CLI_ERROR_MANIFEST_VALIDATION_FAILURE ((HRESULT)0x8A150029)
#define APPINSTALLER_CLI_ERROR_INVALID_MANIFEST ((HRESULT)0x8A15002A)

namespace AppInstaller
{
Expand Down
6 changes: 6 additions & 0 deletions src/AppInstallerRepositoryCore/Manifest/YamlParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,12 @@ namespace AppInstaller::Manifest

std::vector<ValidationError> YamlParser::ParseManifest(const YAML::Node& rootNode, Manifest& manifest, bool fullValidation)
{
// Detects empty files with a better error.
if (!rootNode.IsMap())
{
THROW_EXCEPTION_MSG(ManifestException(APPINSTALLER_CLI_ERROR_INVALID_MANIFEST), "The manifest does not contain a valid root.");
}

// Detect manifest version first to determine expected fields
// Use index to access ManifestVersion directly. If there're duplicates or other general errors, it'll be detected in later
// processing of iterating the whole manifest.
Expand Down

0 comments on commit 7afa8a5

Please sign in to comment.