Skip to content

Commit

Permalink
Addressing PR review comments: Simplify schema header validation erro…
Browse files Browse the repository at this point in the history
…r messages

1. Updated error messages in multiple files to simplify instructions for verifying schema headers.
2.  Removed detailed YAML node verification instructions.
3. Modified function signatures in ManifestSchemaValidation.cpp to remove const qualifiers.
  • Loading branch information
Madhusudhan-MSFT committed Jan 14, 2025
1 parent 4b18e9e commit 097ee92
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/AppInstallerCLIE2ETests/ValidateCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public void ValidateManifestV1_10_SchemaHeaderExpectWarnings()
result = TestCommon.RunAICLICommand("validate", TestCommon.GetTestDataFile("Manifests\\TestWarningManifestV1_10-SchemaHeaderInvalid.yaml"));
Assert.AreEqual(Constants.ErrorCode.ERROR_MANIFEST_VALIDATION_WARNING, result.ExitCode);
Assert.True(result.StdOut.Contains("Manifest validation succeeded with warnings."));
Assert.True(result.StdOut.Contains("Manifest Warning: The schema header is invalid. Please verify that the schema header is present and formatted correctly as a valid YAML node with the appropriate commented syntax."));
Assert.True(result.StdOut.Contains("Manifest Warning: The schema header is invalid. Please verify that the schema header is present and formatted correctly."));

result = TestCommon.RunAICLICommand("validate", TestCommon.GetTestDataFile("Manifests\\TestWarningManifestV1_10-SchemaHeaderURLPatternMismatch.yaml"));
Assert.AreEqual(Constants.ErrorCode.ERROR_MANIFEST_VALIDATION_WARNING, result.ExitCode);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public void WinGetUtil_ValidateManifest_V1_10_WithSchemaHeader_Failure(WinGetUti

// Schema header invalid
manifestsFilePath = TestCommon.GetTestDataFile(@"Manifests\TestWarningManifestV1_10-SchemaHeaderInvalid.yaml");
expectedError = "Manifest Error: The schema header is invalid. Please verify that the schema header is present and formatted correctly as a valid YAML node with the appropriate commented syntax.";
expectedError = "Manifest Error: The schema header is invalid. Please verify that the schema header is present and formatted correctly.";
this.ValidateSchemaHeaderFailure(manifestsFilePath, createManifestOption, expectedError);

// Schema header URL pattern mismatch
Expand Down
2 changes: 1 addition & 1 deletion src/AppInstallerCLITests/YamlManifest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1855,7 +1855,7 @@ TEST_CASE("ManifestV1_10_SchemaHeaderValidations", "[ManifestValidation]")
REQUIRE_THROWS_MATCHES(YamlParser::CreateFromPath(TestDataFile("ManifestV1_10-Bad-SchemaHeaderNotFound.yaml"),validateOption), ManifestException, ManifestExceptionMatcher("Schema header not found"));

// Schema header not valid
REQUIRE_THROWS_MATCHES(YamlParser::CreateFromPath(TestDataFile("ManifestV1_10-Bad-SchemaHeaderInvalid.yaml"), validateOption), ManifestException, ManifestExceptionMatcher("The schema header is invalid. Please verify that the schema header is present and formatted correctly as a valid YAML node with the appropriate commented syntax"));
REQUIRE_THROWS_MATCHES(YamlParser::CreateFromPath(TestDataFile("ManifestV1_10-Bad-SchemaHeaderInvalid.yaml"), validateOption), ManifestException, ManifestExceptionMatcher("The schema header is invalid. Please verify that the schema header is present and formatted correctly."));

// Schema header URL does not match the expected schema URL
REQUIRE_THROWS_MATCHES(YamlParser::CreateFromPath(TestDataFile("ManifestV1_10-Bad-SchemaHeaderURLPatternMismatch.yaml"), validateOption), ManifestException, ManifestExceptionMatcher("The schema header URL does not match the expected pattern."));
Expand Down
10 changes: 2 additions & 8 deletions src/AppInstallerCommonCore/Manifest/ManifestSchemaValidation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ namespace AppInstaller::Manifest::YamlParser
return result;
}

bool SearchForManifestSchemaHeaderString(std::shared_ptr<std::istream> yamlInputStream, const size_t& rootNodeBeginsAtLine, ManifestSchemaHeader& schemaHeader)
bool SearchForManifestSchemaHeaderString(std::shared_ptr<std::istream> yamlInputStream, size_t rootNodeBeginsAtLine, ManifestSchemaHeader& schemaHeader)
{
std::string line;
size_t currentLine = 1;
Expand Down Expand Up @@ -290,16 +290,10 @@ namespace AppInstaller::Manifest::YamlParser
return errors;
}

std::vector<ValidationError> ValidateYamlManifestSchemaHeader(const YamlManifestInfo& manifestInfo, const ManifestVer& manifestVersion, const ValidationError::Level& errorLevel)
std::vector<ValidationError> ValidateYamlManifestSchemaHeader(const YamlManifestInfo& manifestInfo, const ManifestVer& manifestVersion, ValidationError::Level errorLevel)
{
std::vector<ValidationError> errors;

if (manifestInfo.ManifestType == ManifestTypeEnum::Shadow)
{
// There's no schema for a shadow manifest.
return errors;
}

size_t rootNodeLine = manifestInfo.Root.Mark().line;
std::string schemaHeaderString;

Expand Down
2 changes: 1 addition & 1 deletion src/AppInstallerCommonCore/Manifest/ManifestValidation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ namespace AppInstaller::Manifest
{ AppInstaller::Manifest::ManifestError::MsixSignatureHashFailed, "Failed to calculate MSIX signature hash.Please verify that the input file is a valid, signed MSIX."sv },
{ AppInstaller::Manifest::ManifestError::ShadowManifestNotAllowed, "Shadow manifest is not allowed." },
{ AppInstaller::Manifest::ManifestError::SchemaHeaderNotFound, "Schema header not found." },
{ AppInstaller::Manifest::ManifestError::InvalidSchemaHeader , "The schema header is invalid. Please verify that the schema header is present and formatted correctly as a valid YAML node with the appropriate commented syntax."sv },
{ AppInstaller::Manifest::ManifestError::InvalidSchemaHeader , "The schema header is invalid. Please verify that the schema header is present and formatted correctly."sv },
{ AppInstaller::Manifest::ManifestError::SchemaHeaderManifestTypeMismatch , "The manifest type in the schema header does not match the ManifestType property value in the manifest."sv },
{ AppInstaller::Manifest::ManifestError::SchemaHeaderManifestVersionMismatch, "The manifest version in the schema header does not match the ManifestVersion property value in the manifest."sv },
{ AppInstaller::Manifest::ManifestError::SchemaHeaderUrlPatternMismatch, "The schema header URL does not match the expected pattern."sv },
Expand Down

0 comments on commit 097ee92

Please sign in to comment.