Gateway raw reads return a stored NULL as value 0 (SQL backends return null) #690

Closed
opened 2026-10-12 16:03:37 -04:00 by dohertj2 · 1 comment
Owner

Found by the #685–#688 live AVEVA gate (2026-10-12), pre-existing.

A stored NULL sample inside the window comes back from Gateway HistoryRead-Raw as value 0 with a Bad status (histsdk puts a value on every row; a NULL row is value 0 + Bad OPC quality). The SqlServer and QuestDB backends return a null value with the Bad status. Clients that read the value without checking the status see a fabricated 0.

Suggested fix: in SampleMapper.ToSnapshots, null the value when the OPC quality is Bad (as the aggregate mapper already does for no-data rows), and pin it with a wire-shaped fake.

Found by the #685–#688 live AVEVA gate (2026-10-12), pre-existing. A stored NULL sample inside the window comes back from Gateway HistoryRead-Raw as value `0` with a Bad status (histsdk puts a value on every row; a NULL row is value 0 + Bad OPC quality). The SqlServer and QuestDB backends return a null value with the Bad status. Clients that read the value without checking the status see a fabricated 0. Suggested fix: in `SampleMapper.ToSnapshots`, null the value when the OPC quality is Bad (as the aggregate mapper already does for no-data rows), and pin it with a wire-shaped fake.
Author
Owner

Fixed on master 15ccd9b7 (merge f0d064a6): SampleMapper.ToSnapshot nulls the value whenever the mapped status is Bad (AVEVA stores a Bad sample as NULL; Uncertain keeps its value). Applies to raw and AtTime; per-sample aggregates were already correct.

Live AVEVA gate PASS: a stored NULL returns null + Bad in raw, reverse, bounded and AtTime reads. (AtTime has separate interpolation issues — #693.)

Fixed on master `15ccd9b7` (merge `f0d064a6`): `SampleMapper.ToSnapshot` nulls the value whenever the mapped status is Bad (AVEVA stores a Bad sample as NULL; Uncertain keeps its value). Applies to raw and AtTime; per-sample aggregates were already correct. **Live AVEVA gate PASS:** a stored NULL returns null + Bad in raw, reverse, bounded and AtTime reads. (AtTime has separate interpolation issues — #693.)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: dohertj2/lmxopcua#690