telefonicaid / fiware-orion

Context Broker and CEF building block for context data management, providing NGSI interfaces.
https://github.com/telefonicaid/fiware-orion/blob/master/doc/manuals/orion-api.md
GNU Affero General Public License v3.0
210 stars 265 forks source link

[BUG] in POST v2/subscriptions, if "condition/attributes" has empty values #1983

Closed iariasleon closed 8 years ago

iariasleon commented 8 years ago

in POST v2/subscriptions, if "condition/attributes" has empty values, returns a 200 in http code and a payload as a v1 error instead of a v2 error.

See "Field syntax restrictions" in fiware-ngsiv2-reference:

The rules are:

Allowed characters are the ones in the plain ASCII set except the following ones: control characters, whitespace, &, ?, / and #.

  • Maximum field length is 256 characters.
  • Minimum field length is 1 character.

    subscription request

POST http://localhost:1026/v2/subscriptions
Content-Type: application/json
Fiware-Service: test_condition_attributes_limit_exceed
Fiware-ServicePath: /test
{"notification": {"callback": "http://localhost:1234", "attributes": ["temperature"]}, "expires": "2016-04-05T14:00:00.00Z", "subject": {"entities": [{"idPattern": ".*"}], "condition": {"attributes": [""]}}}

subcription response

http code: 200
date: Fri, 01 Apr 2016 08:21:34 GMT
connection: Keep-Alive
content-type: application/json
content-length: 175
{
  "subscribeError" : {
    "errorCode" : {
      "code" : "400",
      "reasonPhrase" : "Bad Request",
      "details" : "invalid payload: empty condValue name"
    }
  }
}

Expected response

http code: 400
{"error":"BadRequest","description":"not defined yet"}
iariasleon commented 8 years ago

LGTM

http code: 400 - Bad Request
headers:
   date: Thu, 16 Jun 2016 12:51:02 GMT
   fiware-correlator: fb5782c6-33c0-11e6-a5ff-005056a20feb
   connection: Keep-Alive
   content-type: application/json
   content-length: 61
payload: {"error":"BadRequest","description":"attrs element is empty"}