telefonicaid / telefonicaid/iotagent-node-lib
Avoid update with empty entities when using multi entity plugin or explicitAttrs=true
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 62
- Forks
- 90
- Avg merge
- 2h 35m
- Merged PRs (30d)
- 1
Description
When using multi entity plugin together with expressionAttrs, a particular situation could happen when the base entity does not have any attribute within the measure.
As an example, provisioning a group like this one:
{
"commands": [],
"type": "GPS",
"lazy": [],
"active": [
{
"name": "explicit",
"type": "number",
"entity_name": "SO5",
"object_id": "x"
},
{
"name": "explicit",
"type": "number",
"entity_name": "SO6",
"object_id": "y"
}
],
"explicitAttrs": true
}
And sending a measure like this one to a device gps1:
[
{
"name": "x",
"type": "Number",
"value": 52
},
{
"name": "y",
"type": "Number",
"value": 13
},
{
"name": "z",
"type": "Number",
"value": 12
}
]
Would result on a update operation against CB like this one:
{
"actionType": "update",
"entities": [
{
"id": "gps1",
"type": "GPS"
},
{
"explicit": {
"type": "number",
"value": 52
},
"type": "GPS",
"id": "SO5"
},
{
"explicit": {
"type": "number",
"value": 13
},
"type": "GPS",
"id": "SO6"
}
]
}
In which the entity gps1 is updated without having any attribute.
Makes this sense? Should this entity be removed from update list?
According to @fgalan , this does not have a huge impact on CB.
This is related with test/unit/ngsiv2/expressions/jexlBasedTransformations-test.js changes added in PR #1157
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with test/unit/ngsiv2/expressions/jexlBasedTransformations-test.js and the changes from PR #1157, then trace how the multi-entity and expressionAttrs inputs produce the update payload. Done means the expected handling of a base entity with no attributes is decided and covered by a regression test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100