FIWARE / context.Orion-LD

Context Broker and CEF building block for context data management which supports both the NGSI-LD and the NGSI-v2 APIs
https://www.etsi.org/deliver/etsi_gs/CIM/001_099/009/01.06.01_60/gs_CIM009v010601p.pdf
GNU Affero General Public License v3.0
50 stars 43 forks source link

Response of POST /ngsi-ld/v1/entityOperations/create is corrupted #776

Closed fisuda closed 3 years ago

fisuda commented 3 years ago

The behavior of POST /ngsi-ld/v1/entityOperations/create seems to be changed between 0.7-PRE-105 and 0.7-PRE-106. The response body is corrupted.

HTTP/1.1 201 Created
Connection: Keep-Alive
Content-Length: 28
Content-Type: application/ld+json
Date: Sat, 27 Mar 2021 22:59:35 GMT

["3��8","���8","��8"]
HTTP/1.1 200 OK
Connection: Keep-Alive
Content-Length: 188
Content-Type: application/ld+json
Date: Sat, 27 Mar 2021 22:51:23 GMT

{"@context":"https://context.lab.letsfiware.jp/ngsi-context.jsonld","success":["urn:ngsi-ld:TemperatureSensor:002","urn:ngsi-ld:TemperatureSensor:003","urn:ngsi-ld:TemperatureSensor:004"],"errors":[]}

The following is a test script to reproduce it.

#!/bin/sh
curl -iX POST 'http://orion-ld:1026/ngsi-ld/v1/entityOperations/create' \
-H 'Content-Type: application/json' \
-H 'Link: <https://context.lab.letsfiware.jp/ngsi-context.jsonld>; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json"' \
-H 'Accept: application/ld+json' \
--data-raw '[
    {
      "id": "urn:ngsi-ld:TemperatureSensor:002",
      "type": "TemperatureSensor",
      "category": {
            "type": "Property",
            "value": "sensor"
      },
      "temperature": {
            "type": "Property",
            "value": 20,
            "unitCode": "CEL"
      }
    },
    {
      "id": "urn:ngsi-ld:TemperatureSensor:003",
      "type": "TemperatureSensor",
      "category": {
            "type": "Property",
            "value": "sensor"
      },
      "temperature": {
            "type": "Property",
            "value": 2,
            "unitCode": "CEL"
      }
    },
     {
      "id": "urn:ngsi-ld:TemperatureSensor:004",
      "type": "TemperatureSensor",
      "category": {
            "type": "Property",
            "value": "sensor"
      },
      "temperature": {
            "type": "Property",
            "value": 100,
            "unitCode": "CEL"
      }
    }
]'
$ docker images | grep orion-ld
fiware/orion-ld                          0.7-PRE-106                    29fff22b88c3   2 days ago      978MB
fiware/orion-ld                          0.7-PRE-105                    9d814ba66390   6 days ago      978MB
kzangeli commented 3 years ago

ok! I reproduced the bug - should be an easy fix. It's weird, I have a functest doing something quite similar and it's working just fine.

kzangeli commented 3 years ago

I believe PR #777 fixes the problem. However, github actions is really slow today ... the jobs for the PR are queued but not starting. Can't merge to develop until I've seen all jobs finish successfully.

Meanwhile, if you are in a hurry, change the Accept: application/ld+json for Accept: application/json - that should "neutralize" the bug.

Thanks for reporting!

fisuda commented 3 years ago

Thank you for your prompt response. I'm not in hurry. After the new Docker image is created, I will test it.

fisuda commented 3 years ago

I have confirmed that the bug has been fixed by #777.

HTTP/1.1 201 Created
Connection: Keep-Alive
Content-Length: 109
Content-Type: application/ld+json
Date: Sun, 28 Mar 2021 11:15:32 GMT

["urn:ngsi-ld:TemperatureSensor:002","urn:ngsi-ld:TemperatureSensor:003","urn:ngsi-ld:TemperatureSensor:004"]
$ docker images | grep orion-ld
fiware/orion-ld                          0.7-PRE-107                    1a423b53e33a   16 minutes ago   979MB

Thanks!