Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] in POST v2/subscriptions, if "entities/type" has empty values #1985

Closed
iariasleon opened this issue Apr 1, 2016 · 5 comments
Closed
Assignees
Milestone

Comments

@iariasleon
Copy link
Contributor

iariasleon commented Apr 1, 2016

in POST v2/subscriptions, if "entities/type" has empty values, returns a 201 in http code and type field does not exist in DB.

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_entities_type
Fiware-ServicePath: /test
{
    "notification": {
        "callback": "http://localhost:1234",
        "attributes": ["temperature"]
    },
    "expires": "2016-04-05T14:00:00.00Z",
    "subject": {
        "entities": [{
            "type": "",
            "id": "room"
        }],
        "condition": {
            "attributes": ["temperature"]
        }
    }
}

subscription response

http code: 201
date: Fri, 01 Apr 2016 10:24:27 GMT
connection: Keep-Alive
content-length: 0
location: /v2/subscriptions/56fe524798f47d94682d620c

doc in mongo

{"reference': "http://localhost:1234', "throttling': 0L, "expression': {"q': "', "geometry': "', "georel': "', "coords': "'}, "format': "JSON', "entities': [{"id': "room', "isPattern': "false'}], "expiration': 1459864800L, "servicePath': "/test', "_id': ObjectId('56fe524798f47d94682d620c'), "conditions': [{"type': "ONCHANGE', "value': ["temperature']}], "attrs': ["temperature']}

expected response

http code: 400
{"error":"BadRequest","description":"not defined yet"}
@iariasleon
Copy link
Contributor Author

Re-tested in the CB version. It issue still fails and returns 201-Created

  "version" : "1.2.0-next",
  "git_hash" : "d81dcf28e71d8d63dc0929ef7a6b73d7db47421b"

@kzangeli kzangeli self-assigned this Jan 16, 2017
@kzangeli
Copy link
Member

Entity::type is not a mandatory field, perhaps this is simply expected behaviour?

@fgalan
Copy link
Member

fgalan commented Jan 17, 2017

Spec says:

If omitted, it means "any entity type"

which is not the same that having type but with empty value (""). In fact, that usage doesn't make sense, as it would be like saying that the type of the entity must be "", which is an ilegal value, as @iariasleon correctly points out.

Looking to https://fiware-orion.readthedocs.io/en/master/user/ngsiv2_implementation_notes/index.html we have:

type or typePattern: optional (but both at the same time is not allowed). type must follow NGSIv2 restrictions for IDs. typePattern must be not empty and a valid regex.

That should be enhance adding "(if present it must be not empty, i.e. "" is not allowed)"

@fgalan
Copy link
Member

fgalan commented Jan 17, 2017

Fixed by PR #2821. @iariasleon pls check again once the PR gets merged.

@iariasleon
Copy link
Contributor Author

LGTM

http code: 400 - Bad Request
headers:
   Connection: Keep-Alive
   Content-Length: 85
   Content-Type: application/json
   Fiware-Correlator: 4abcc298-de2c-11e6-bde5-005056a20feb
   Date: Thu, 19 Jan 2017 09:47:29 GMT
payload: {"error":"BadRequest","description":"entity type length: 0, min length supported: 1"}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants