Registry: one throw for a missing or non-array ships; tests pin refusal codes, title bound and plan order
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
46d92200e5
commit
a43f90b48d
2 changed files with 38 additions and 10 deletions
|
|
@ -43,16 +43,7 @@ public sealed class ConceptSubjectRegistry(
|
|||
public static IReadOnlyList<ManifestShip> ParseManifest(string json)
|
||||
{
|
||||
using var document = ParseDocument(json);
|
||||
if (document.RootElement.ValueKind != JsonValueKind.Object)
|
||||
{
|
||||
throw new ManifestRefusedException("ships", "Missing");
|
||||
}
|
||||
|
||||
if (!document.RootElement.TryGetProperty("ships", out var ships))
|
||||
{
|
||||
throw new ManifestRefusedException("ships", "Missing");
|
||||
}
|
||||
|
||||
var ships = ShipsOf(document.RootElement);
|
||||
if (ships.ValueKind != JsonValueKind.Array)
|
||||
{
|
||||
throw new ManifestRefusedException("ships", "Missing");
|
||||
|
|
@ -91,6 +82,16 @@ public sealed class ConceptSubjectRegistry(
|
|||
return result;
|
||||
}
|
||||
|
||||
private static JsonElement ShipsOf(JsonElement root)
|
||||
{
|
||||
if (root.ValueKind != JsonValueKind.Object)
|
||||
{
|
||||
return default;
|
||||
}
|
||||
|
||||
return root.TryGetProperty("ships", out var ships) ? ships : default;
|
||||
}
|
||||
|
||||
private static JsonDocument ParseDocument(string json)
|
||||
{
|
||||
try
|
||||
|
|
|
|||
Loading…
Reference in a new issue