fix(adminui): reject AbLegacy array length >256 at author-time (review I-3)
v2-ci / build (push) Failing after 1m3s
v2-ci / unit-tests (tests/Core/ZB.MOM.WW.OtOpcUa.Cluster.Tests) (push) Has been skipped
v2-ci / unit-tests (tests/Server/ZB.MOM.WW.OtOpcUa.ControlPlane.Tests) (push) Has been skipped
v2-ci / unit-tests (tests/Server/ZB.MOM.WW.OtOpcUa.OpcUaServer.Tests) (push) Has been skipped
v2-ci / unit-tests (tests/Server/ZB.MOM.WW.OtOpcUa.Runtime.Tests) (push) Has been skipped
v2-ci / unit-tests (tests/Server/ZB.MOM.WW.OtOpcUa.Security.Tests) (push) Has been skipped
v2-ci / integration (tests/Server/ZB.MOM.WW.OtOpcUa.Host.IntegrationTests) (push) Has been skipped
v2-ci / integration (tests/Server/ZB.MOM.WW.OtOpcUa.OpcUaServer.IntegrationTests) (push) Has been skipped

This commit is contained in:
Joseph Doherty
2026-06-16 22:31:42 -04:00
parent 3bb2031d1d
commit 0f92e9e238
2 changed files with 45 additions and 1 deletions
@@ -44,5 +44,19 @@ public sealed class AbLegacyTagConfigModel
/// <summary>Validation hook; returns an error message or null when the model is valid.</summary>
public string? Validate()
=> string.IsNullOrWhiteSpace(Address) ? "Address is required." : null;
{
if (string.IsNullOrWhiteSpace(Address))
return "Address is required.";
// Array-length cap: PCCC data-file elements are limited to AbLegacyArray.MaxElements (256).
// The driver-agnostic materialiser uses the raw arrayLength to set OPC UA ArrayDimensions, but the
// driver clamps to 256 at runtime — so an authored length > 256 produces a Part 6 §5.3.2 mismatch.
// Reject it here at author-time so the error surfaces in the TagModal before the config is saved.
var isArray = TagConfigJson.GetBool(_bag, "isArray");
var arrayLength = TagConfigJson.GetInt(_bag, "arrayLength");
if (isArray && arrayLength > AbLegacyArray.MaxElements)
return $"AbLegacy array length cannot exceed {AbLegacyArray.MaxElements} (PCCC data-file element limit).";
return null;
}
}
@@ -99,4 +99,34 @@ public sealed class AbLegacyTagConfigModelTests
json.ShouldContain("\"deviceHostAddress\":\"ab://host\"");
}
// Array-length cap (review I-3): authored arrayLength > 256 on an AbLegacy array tag must be
// rejected at author-time to prevent a Part 6 §5.3.2 ArrayDimensions mismatch at runtime.
[Fact]
public void Validate_returns_error_when_array_length_exceeds_256()
{
var m = AbLegacyTagConfigModel.FromJson("""{"address":"N7:0","isArray":true,"arrayLength":300}""");
var error = m.Validate();
error.ShouldNotBeNull();
error.ShouldContain("256");
}
[Fact]
public void Validate_returns_null_when_array_length_exactly_256()
{
var m = AbLegacyTagConfigModel.FromJson("""{"address":"N7:0","isArray":true,"arrayLength":256}""");
m.Validate().ShouldBeNull();
}
[Fact]
public void Validate_returns_null_for_scalar_tag_regardless_of_no_array_length()
{
var m = AbLegacyTagConfigModel.FromJson("""{"address":"N7:0"}""");
m.Validate().ShouldBeNull();
}
}