From 0a535cd4a5f23708c102f43353ed3ecda3a88d66 Mon Sep 17 00:00:00 2001 From: Joseph Doherty Date: Sat, 16 May 2026 06:08:06 -0400 Subject: [PATCH] fix(triggers): don't false-flag Children/Parent attribute refs in expression validation --- .../Validation/ValidationService.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/ScadaLink.TemplateEngine/Validation/ValidationService.cs b/src/ScadaLink.TemplateEngine/Validation/ValidationService.cs index 514c109..4c81246 100644 --- a/src/ScadaLink.TemplateEngine/Validation/ValidationService.cs +++ b/src/ScadaLink.TemplateEngine/Validation/ValidationService.cs @@ -428,6 +428,18 @@ public class ValidationService while ((index = expression.IndexOf(marker, index, StringComparison.Ordinal)) >= 0) { + // Only treat this as a self-attribute reference when it is not a member + // access. A bare `Attributes["X"]` resolves against the flattened + // configuration; `Children["Pump"].Attributes["X"]` and + // `Parent.Attributes["X"]` are member accesses (preceded by '.') whose + // dotted/composed canonical names cannot be checked against the flat + // self-attribute set — skip them rather than emit a false positive. + if (index > 0 && expression[index - 1] == '.') + { + index += marker.Length; + continue; + } + var cursor = index + marker.Length; // Skip whitespace between '[' and the literal. while (cursor < expression.Length && char.IsWhiteSpace(expression[cursor]))