Skip to content

Commit

Permalink
Merge #4020 Improve netkan relationship error message
Browse files Browse the repository at this point in the history
  • Loading branch information
HebaruSan committed Feb 10, 2024
2 parents d6bf6e9 + 2035194 commit c91a46f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ All notable changes to this project will be documented in this file.

- [Policy] Fix #3518 rewrite de-indexing policy (#3993 by: JonnyOThan; reviewed: HebaruSan)
- [Netkan] Fix null reference exception in swinfo transformer (#3999 by: HebaruSan)
- [Netkan] Improve netkan relationship error message (#4020 by: HebaruSan)

## v1.34.4 (Niven)

Expand Down
4 changes: 1 addition & 3 deletions Netkan/Validators/ObeysCKANSchemaValidator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ public void Validate(Metadata metadata)
var errors = CKANSchema.schema.Validate(metadata.Json());
if (errors.Any())
{
string msg = errors
.Select(err => $"{err.Path}: {err.Kind}")
.Aggregate((a, b) => $"{a}\r\n{b}");
var msg = string.Join(", ", errors.Select(err => $"{err.Path}: {err.Kind}"));
throw new Kraken($"Schema validation failed: {msg}");
}
}
Expand Down
7 changes: 4 additions & 3 deletions Netkan/Validators/RelationshipsValidator.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
using System.Linq;

using Newtonsoft.Json.Linq;

using CKAN.Versioning;
using CKAN.NetKAN.Model;
using System.Linq;

namespace CKAN.NetKAN.Validators
{
Expand All @@ -18,7 +20,7 @@ public void Validate(Metadata metadata)
{
throw new Kraken("spec_version v1.2+ required for 'supports'");
}
foreach (JObject rel in json[relName].Cast<JObject>())
foreach (var rel in json[relName].Children<JObject>())
{
if (rel.ContainsKey("any_of"))
{
Expand Down Expand Up @@ -65,7 +67,6 @@ public void Validate(Metadata metadata)
}
}
}

}

private static readonly string[] relProps = new string[]
Expand Down

0 comments on commit c91a46f

Please sign in to comment.