telefonicaid / telefonicaid/iotagent-node-lib

API does not return device metadata (update metadata not working)

Open
#1,115 10 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

help wanted
Dominant language
JavaScript
Stars
62
Forks
90
Avg merge
2h 35m
Merged PRs (30d)
1

Description

Hello,

I recognised that the endpoint to retrieve a device by id does not return the metadata added to attributes as documented
in the nodelib docs.

This happens although the metadata is correctly posted to the create endpoint and the referenced entity is correctly initialised:

How to reproduce:

I sent this payload to the create endpoint:

"devices": [
    {
      "device_id": "device_with_meta",
      "service": null,
      "service_path": "/",
      "entity_name": "test_entity",
      "entity_type": "test_entity_type",
      "timezone": "Europe/Berlin",
      "timestamp": null,
      "apikey": "1234",
      "endpoint": null,
      "protocol": null,
      "transport": "HTTP",
      "lazy": [],
      "commands": [],
      "attributes": [
        {
          "name": "temperature",
          "type": "Number",
          "metadata": {
            "accuracy": {
              "type": "Text",
              "value": "+-5%"
            }
          },
          "expression": null,
          "entity_name": null,
          "entity_type": null,
          "reverse": null,
          "object_id": "temperature"
        }
      ],
      "static_attributes": [],
      "internal_attributes": null,
      "expressionLanguage": null,
      "explicitAttrs": false,
      "ngsiVersion": "v2"
    }
]

The created then entity looks like this:

    {
      "id": "test_entity",
      "type": "test_entity_type",
      "TimeInstant": {
        "type": "DateTime",
        "value": "2021-05-06T07:34:20.417Z",
        "metadata": {}
      },
      "temperature": {
        "type": "Number",
        "value": null,
        "metadata": {
          "accuracy": {
            "type": "Text",
            "value": "+-5%"
          }
        }
      }
    }

However, retrieving the device by its id returns this:


{
  "device_id": "device_with_meta",
  "service": "filip",
  "service_path": "/testing",
  "entity_name": "test_entity",
  "entity_type": "test_entity_type",
  "apikey": "1234",
  "transport": "HTTP",
  "lazy": [],
  "commands": [],
  "attributes": [
    {
      "name": "temperature",
      "type": "Number",
      "object_id": "temperature"
    }
  ],
  "static_attributes": [],
  "explicitAttrs": false,
  "ngsiVersion": "v2"
}

Am I missing an undocumented query parameter here or is it just a bug?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the device creation and retrieve-by-ID API entry points described in the nodelib API documentation, then reproduce the request using the supplied payload. Compare the returned device attributes with the entity shown in the issue, focusing on whether metadata is dropped during retrieval. Done means the retrieve response includes the attribute metadata posted during creation.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.