telefonicaid / iotagent-node-lib

Module to enable IoT Agent developers to build custom agents for their devices that can easily connect to NGSI Context Brokers
https://iotagent-node-lib.rtfd.io/
GNU Affero General Public License v3.0
60 stars 85 forks source link

Fix: Remove nulls from context before evaluating expressions #1474

Closed mapedraza closed 11 months ago

mapedraza commented 11 months ago

This PR delete null elements from context. This fix arithmetic problems due to JEXL library bug: https://github.com/telefonicaid/iotagent-node-lib/issues/1440 https://github.com/TomFrost/Jexl/issues/133

Overpasses: https://github.com/telefonicaid/iotagent-node-lib/pull/1471

mapedraza commented 11 months ago

From #1471

Conclusions:

  • case b (v*3)
    • For Null values, is always failing (treating Null as 0)
    • For NaN values, it works well, giving Null as response.
  • case f ((v*3)==Null?'soy null':'no soy null') is always failing
  • Using explicitAttrs acts as sending a measurement with null value

This PR solves case b. Case f is still failing.

AlvaroVega commented 11 months ago

Not sure if this approach is introducing a bit of overhead, and maybe just only at measure level approach could be enough https://github.com/telefonicaid/iotagent-node-lib/pull/1473 but LGTM