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 v1/updateContext if servicePath exceed the max length allowed #1774

Closed
iariasleon opened this issue Feb 8, 2016 · 5 comments
Closed
Assignees
Labels
Milestone

Comments

@iariasleon
Copy link
Contributor

Similar to #1423

The servicePath allowed ten levels with 50 char each one, but now if we use 50 or more in several levels, ex: /tester1testcom/12345678901234567890123456789012, it is returned an error. Reference: #1764.

Append Request

POST http://localhost:1026/v1/updateContext
Fiware-Service: default
Fiware-ServicePath: /tester1testcom/12345678901234567890123456789012
Content-Type: application/json
{
    "contextElements": [
        {
            "type": "House",
            "isPattern": "false",
            "id": "Room",
            "attributes": [
            {
                "name": "temperature",
                "type": "float",
                "value": "23"
            }
            ]
        }
    ],
    "updateAction": "APPEND"
}

Append response

Status: 200: OK
<updateContextResponse>
  <contextResponseList>
    <contextElementResponse>
      <contextElement>
        <entityId type="House" isPattern="false">
          <id>Room</id>
        </entityId>
        <contextAttributeList>
          <contextAttribute>
            <name>temperature</name>
            <type>float</type>
            <contextValue></contextValue>
          </contextAttribute>
        </contextAttributeList>
      </contextElement>
      <statusCode>
        <code>200</code>
        <reasonPhrase>OK</reasonPhrase>
      </statusCode>
    </contextElementResponse>
  </contextResponseList>
</updateContextResponse>

If we try to use the same previous request, returns an error, but if we reduce the service-Path length, works perfectly.

Append response

Status: 200: OK
<updateContextResponse>
  <contextResponseList>
    <contextElementResponse>
      <contextElement>
        <entityId type="House" isPattern="false">
          <id>Room</id>
        </entityId>
        <contextAttributeList>
          <contextAttribute>
            <name>temperature</name>
            <type>float</type>
            <contextValue></contextValue>
          </contextAttribute>
        </contextAttributeList>
      </contextElement>
      <statusCode>
        <code>472</code>
        <reasonPhrase>request parameter is invalid/not allowed</reasonPhrase>
        <details>Database Error &#40;collection: orion-default.entities - insert&#40;&#41;: { _id: { id: \&quot;Room\&quot;, type: \&quot;House\&quot;, servicePath: \&quot;/tester1testcom/12345678901234567890123456789012\&quot; }, attrNames: [ \&quot;temperature\&quot; ], attrs: { temperature: { type: \&quot;float\&quot;, creDate: 1454929131, modDate: 1454929131, value: \&quot;23\&quot; } }, creDate: 1454929131, modDate: 1454929131 } - exception: OperationException: { index: 0, code: 11000, errmsg: \&quot;insertDocument :: caused by :: 11000 E11000 duplicate key error index: orion-default.entities.$_id_  dup key: { : { id: \&quot;Room\&quot;, type: \&quot;House\&quot;, service...\&quot;, op: { _id: { id: \&quot;Room\&quot;, type: \&quot;House\&quot;, servicePath: \&quot;/tester1testcom/12345678901234567890123456789012\&quot; }, attrNames: [ \&quot;temperature\&quot; ], attrs: { temperature: { type: \&quot;float\&quot;, creDate: 1454929131, modDate: 1454929131, value: \&quot;23\&quot; } }, creDate: 1454929131, modDate: 1454929131 } }&#41;</details>
      </statusCode>
    </contextElementResponse>
  </contextResponseList>
</updateContextResponse>

@iariasleon iariasleon added this to the 0.28.0 milestone Feb 8, 2016
@fgalan
Copy link
Member

fgalan commented Feb 8, 2016

It would be better to use JSON encoding for these tests, as XML is deprecated.

@iariasleon
Copy link
Contributor Author

Yes, a forget the Accept header, but the request is in json encoding

I have tried with Accept: application/json header and the same request has returned:

Status: 200: OK
{
  "contextResponses" : [
    {
      "contextElement" : {
        "type" : "House",
        "isPattern" : "false",
        "id" : "Room",
        "attributes" : [
          {
            "name" : "temperature",
            "type" : "float",
            "value" : ""
          }
        ]
      },
      "statusCode" : {
        "code" : "472",
        "reasonPhrase" : "request parameter is invalid/not allowed",
        "details" : "Database Error &#40;collection: orion-default.entities - insert&#40;&#41;: { _id: { id: \\&quot;Room\\&quot;, type: \\&quot;House\\&quot;, servicePath: \\&quot;/tester1testcom/12345678901234567890123456789012\\&quot; }, attrNames: [ \\&quot;temperature\\&quot; ], attrs: { temperature: { type: \\&quot;float\\&quot;, creDate: 1454941940, modDate: 1454941940, value: \\&quot;23\\&quot; } }, creDate: 1454941940, modDate: 1454941940 } - exception: OperationException: { index: 0, code: 11000, errmsg: \\&quot;insertDocument :: caused by :: 11000 E11000 duplicate key error index: orion-default.entities.$_id_  dup key: { : { id: \\&quot;Room\\&quot;, type: \\&quot;House\\&quot;, service...\\&quot;, op: { _id: { id: \\&quot;Room\\&quot;, type: \\&quot;House\\&quot;, servicePath: \\&quot;/tester1testcom/12345678901234567890123456789012\\&quot; }, attrNames: [ \\&quot;temperature\\&quot; ], attrs: { temperature: { type: \\&quot;float\\&quot;, creDate: 1454941940, modDate: 1454941940, value: \\&quot;23\\&quot; } }, creDate: 1454941940, modDate: 1454941940 } }&#41;"
      }
    }
  ]
}

@iariasleon
Copy link
Contributor Author

These tests are in:

<version>0.27.0-next</version> 
<git_hash>1dbda778ef20a32cdb223cd5fd5eadcff9a3d9e7</git_hash>

@crbrox
Copy link
Member

crbrox commented Feb 10, 2016

@iariasleon

to check and close

@iariasleon
Copy link
Contributor Author

LGTM
The same request (see above) always returns the same response affter of N retries.

{
  "contextResponses" : [
    {
      "contextElement" : {
        "type" : "House",
        "isPattern" : "false",
        "id" : "Room",
        "attributes" : [
          {
            "name" : "temperature",
            "type" : "float",
            "value" : ""
          }
        ]
      },
      "statusCode" : {
        "code" : "200",
        "reasonPhrase" : "OK"
      }
    }
  ]
}

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

No branches or pull requests

3 participants