fix(scripting): #1100 a script result is what an OPC UA node can carry, in both runners — Guid crosses the wire, unpublishable types are refused alike
Where an in-process result really ends up: VirtualTagActor -> VirtualTagHostActor -> OpcUaPublishActor ->
OtOpcUaNodeManager.WriteValueLocked -> SdkValueBoundary.FromClr (VariantHelper.TryCastFrom). Probed against
SDK 2.0.1: Guid / Guid[] become an OPC UA Guid scalar/array; KeyValuePair<,>[] (a returned Dictionary),
decimal, enum, TimeSpan, char, DateTimeOffset, tuples, Nullable<T>[] and rank>1 arrays are refused, so the
node write threw, OpcUaPublishActor logged a Warning, and the node kept its PREVIOUS value and status (a
silent freeze, possibly under Good) while the worker answered "unsupported type".
Decision, per type, by what a client can see:
- Guid (scalar + 1-D array): representable -> the wire gains an additive GUID tag (15, `bytes g = 10`,
16 ToByteArray bytes; a wrong length is a protocol fault). Guid INPUTS cross too. protocol_version stays 1:
the worker ships in the host's script-worker/ folder, and an unknown tag already fails closed.
- Everything FromClr refuses: refused identically in both runners by ScriptResultMaterializer, inside the run,
with one reason ("script threw: The script returned a value of type 'KeyValuePair<Int32, Double>[]', which
an OPC UA node cannot carry; return ..."). A lazy unpublishable sequence is refused before it runs.
ScriptResultMaterializer.PublishableScalarTypes / IsPublishable own the set.
Pins: SdkValueBoundaryScriptResultTests (OpcUaServer.Tests, new Core.Scripting ref) checks IsPublishable ==
"FromClr takes it" over 34 values; ProtocolTests checks the wire carries every publishable type scalar + array;
ParityTests gains guid / guid array / guid list / dictionary / KVP[] / lazy KVPs / KVP / decimal / decimal[] /
enum / TimeSpan / char[] / 2-D rows, a Guid unboxing row, and a positive+negative control. Mutations: with the
type check disabled 11 parity tests fail; with Guid not encoded 9 protocol/parity tests fail.
Behaviour change: a value script returning a Dictionary, decimal, enum, TimeSpan, char or tuple now fails
(Bad + script log) in process too, instead of "succeeding" and leaving its node frozen. Remaining divergence:
a jagged array (publish path carries it as Variant[], worker answers "unsupported type") — follow-up.
This commit is contained in:
+11
-1
@@ -268,7 +268,17 @@ scripted-alarm predicates) runs scripts through the shared `ScriptRunGuard`:
|
||||
since #1092 — it is held to the cap by its `Count`, then copied into the same typed array
|
||||
(`double[]`, …), and refused for an open element type (`List<object>`) — because the out-of-process
|
||||
worker's wire carries arrays but no collection type (it used to answer `unsupported type` while the
|
||||
in-process runner returned the list itself). Arrays, strings and scalars are unchanged. **Still in-process-only limits** (the boundary is
|
||||
in-process runner returned the list itself). Arrays, strings and scalars are unchanged, provided their
|
||||
type is one an OPC UA node can carry. **The result's type is checked too (#1100):** a value script may
|
||||
return null, a `bool`, an integer type, `float`, `double`, `string`, `DateTime` or `Guid`, or a
|
||||
one-dimensional array of one of them (`ScriptResultMaterializer.PublishableScalarTypes` — exactly what
|
||||
the server's OPC UA value boundary turns into a built-in Variant). Anything else — a `Dictionary`
|
||||
(it becomes `KeyValuePair<K,V>[]`), a `decimal`, an enum, a `TimeSpan`, a `char`, a tuple, a 2-D array —
|
||||
fails the run (Bad, script log) in both runners with `script threw: The script returned a value of type
|
||||
'…', which an OPC UA node cannot carry; …`. ⚠️ Behaviour change: in process such a value used to
|
||||
"succeed" and then fail inside the node write, so the node silently kept its previous value and status
|
||||
(only a server-log warning); convert first (`Convert.ToDouble(x)`, or a dictionary's keys and values as
|
||||
two arrays). **Still in-process-only limits** (the boundary is
|
||||
`Scripting:Runner=OutOfProcess`): memory exhaustion inside a run (the sample is after the fact), a
|
||||
non-terminating loop (an orphan thread, then quarantine) and the same two inside an enumerated
|
||||
sequence. See `docs/VirtualTags.md` §"Known resource limits (accepted trade-offs)". The out-of-process
|
||||
|
||||
+12
-5
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user