Skip to content

Error handling when devices not passing the validation #259

@djs0109

Description

@djs0109

Describe the bug
When validation of devices fails, the django debug page will be shown.

To Reproduce
Create the device that has duplicated attribute

import requests
import json

url = "http://...:4041/iot/devices"

payload = json.dumps({
  "devices": [
    {
      "timezone": "Europe/London",
      "timestamp": None,
      "endpoint": None,
      "protocol": "IoTA-JSON",
      "transport": "MQTT",
      "explicitAttrs": False,
      "device_id": "device:001",
      "entity_name": "urn:ngsi-ld:Sensor:001",
      "entity_type": "Sensor",
      "attributes": [
        {
          "name": "temperature",
          "type": "Number",
          "object_id": "t"
        },
        {
          "name": "temperature",
          "type": "Number",
          "object_id": "t"
        }
      ],
      "ngsiVersion": "v2"
    }
  ]
})
headers = {
  'fiware-service': 'test',
  'fiware-servicepath': '/',
  'Content-Type': 'application/json'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)

Then create a project for the same fiware service and open devices module.
You might see the django error pages.

Expected behavior
Ignore the devices that raise the error. Or even give hint about what goes wrong.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions