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

Unexpected Behavior with entityUpdate and notifyOnMetadataChange #4605

Closed
goten002 opened this issue Aug 20, 2024 · 5 comments
Closed

Unexpected Behavior with entityUpdate and notifyOnMetadataChange #4605

goten002 opened this issue Aug 20, 2024 · 5 comments
Labels
Milestone

Comments

@goten002
Copy link
Contributor

When using subscriptions in FIWARE Orion with the alterationTypes field set to entityUpdate and notifyOnMetadataChange set to false, the subscription does not behave as expected. Specifically, the notification fails to trigger when an entity is updated with changes in metadata, when the attribute values remain unchanged. This behavior suggests that the subscription is incorrectly ignoring updates that involve metadata changes while the attribute values stay the same.

  • Orion version: 4.0..0
  • MongoDB version 6.0
  • Env variables: -logLevel DEBUG -dbURI mongodb://mongodb:27017
  • Docker image: fiware/orion:4.0.0

How to reproduce it

  1. Create a subscription::
curl -iX POST 'http://127.0.0.1:1026/v2/subscriptions' \
-H 'Fiware-Service: test' \
-H 'Fiware-ServicePath: /test' \
-H 'Content-Type: application/json' \
-d '{
  "description": "testing-quantumleap-subscription",
  "subject": {
    "entities": [
      {
        "idPattern": ".*",
        "type": "DummyDevice"
      }
    ],
    "condition": {
      "attrs": [
        "temperature",
        "humidity"
      ],
      "notifyOnMetadataChange": false,
      "alterationTypes": [
        "entityUpdate",
        "entityCreate"
      ]
    }
  },
  "notification": {
    "attrs": [
      "temperature",
      "humidity"
    ],
    "onlyChangedAttrs": true,
    "attrsFormat": "normalized",
    "http": {
      "url": "http://quantumleap:8668/v2/notify"
    },
    "metadata": [
      "TimeInstant"
    ]
  }
}'
  1. Create an entity
curl -iX POST 'http://localhost:1026/v2/entities' \
-H 'Fiware-Service: test' \
-H 'Fiware-ServicePath: /test' \
-H 'Content-Type: application/json' \
-d '{
  "id": "dummy-device-01",
  "type": "DummyDevice",
  "temperature": {
    "type": "Number",
    "value": 20,
    "metadata": {
      "TimeInstant": {
        "type": "DateTime",
        "value": "2024-08-20T00:00:00.000Z"
      }
    }
  },
  "humidity": {
    "type": "Number",
    "value": 50,
    "metadata": {
      "TimeInstant": {
        "type": "DateTime",
        "value": "2024-08-20T00:00:00.000Z"
      }
    }
  }
}'
  1. Update Attributes
curl -iX POST 'http://localhost:1026/v2/entities/dummy-device-01/attrs' \
-H 'Fiware-Service: test' \
-H 'Fiware-ServicePath: /test' \
-H 'Content-Type: application/json' \
-d '{
  "temperature": {
    "type": "Number",
    "value": 20,
    "metadata": {
      "TimeInstant": {
        "type": "DateTime",
        "value": "2024-08-20T00:10:00.000Z"
      }
    }
  },
  "humidity": {
    "type": "Number",
    "value": 50,
    "metadata": {
      "TimeInstant": {
        "type": "DateTime",
        "value": "2024-08-20T00:10:00.000Z"
      }
    }
  }
}'

Expected behavior
Following the requests above the notification should be triggered twice: once when the entity is created, and once when the entity is updated, regardless of whether the metadata or the value has changed. Specifically, the update request should trigger the subscription because the alterationTypes field includes entityUpdate. The subscription should react to any update operation, regardless of whether the attribute values change, as long as the update occurs, even if notifyOnMetadataChange is set to false.

Additional information
Interestingly, if the update request is sent without metadata or if the TimeInstant metadata value remains the same as in the create request, the subscription triggers as expected. This suggests that the issue arises only when metadata changes are included in the update.

@goten002 goten002 added the bug label Aug 20, 2024
@goten002 goten002 changed the title Unexpected Behavior with entityUpdate and notifyOnMetadataChange Set to false When Metadata Changes Unexpected Behavior with entityUpdate and notifyOnMetadataChange Aug 20, 2024
@fgalan
Copy link
Member

fgalan commented Aug 21, 2024

Thank you for your detailed report!

We would have a look as soon as possible.

@fgalan
Copy link
Member

fgalan commented Sep 11, 2024

PR #4612 solves this issue

@goten002 it would be great if you could have a look to the test/functionalTest/cases/4605_alterationtype_entityupdate_with_notifyonmetadatachange/alterationtype_entityupdate_with_notifyonmetadatachange.test file added in that PR and provide feedback, please. Step 01-03 are fully based in your issue report and step 04 is an extra addition. As a result, 3 notifications are sent (shown in step 05).

@fgalan fgalan added this to the 4.1.0 milestone Sep 11, 2024
@fgalan
Copy link
Member

fgalan commented Sep 12, 2024

PR #4612 has been merged.

@goten002 it would be great if you could check if the issue has been solved and provide feedback, using the telefonicaiot/fiware-orion:latest image at dockerhub.

@fgalan
Copy link
Member

fgalan commented Sep 12, 2024

We have just released Orion 4.1.0 which includes PR #4612 so we are closing this issue.

However, @goten002 your feedback would still be very valuable. The issue could be reopened if the solution is not correct.

@fgalan fgalan closed this as completed Sep 12, 2024
@goten002
Copy link
Contributor Author

@fgalan Thank you so much for addressing the issue. I’ve tested the functionality with the latest image, and everything seems to be working as expected now. I really appreciate all the work and the fix!

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

2 participants