telefonicaid / fiware-orion

Context Broker and CEF building block for context data management, providing NGSI interfaces.
https://fiware-orion.rtfd.io/
GNU Affero General Public License v3.0
212 stars 265 forks source link

Log error on subscription updates #3531

Closed PiotrBus closed 5 years ago

PiotrBus commented 5 years ago

When subscription is updated, error is logged.

This error log is caused by https://github.com/telefonicaid/fiware-orion/pull/3414

This changes use getStringFieldF(subOrig, CSUB_LASTFAILUREASON); and getIntOrLongFieldAsLongF(subOrig, CSUB_LASTSUCCESSCODE); without checking if this filed exist. So when string field is not exist, function getStringFieldF logs error and return "" empty string.

File: mongoUpdateSubscription.cpp Functions: setLastFailure@546, setLastSuccess@570

Request: PATCH v2/subscriptions/5d42ae11b1c943eb7f5b62c5?options=skipInitialNotification { "id": "5d42ae11b1c943eb7f5b62c5", "subject": { "entities": [ { "idPattern": ".*", "type": "Output" } ] }, "notification": { "http": { "url": "http://192.168.1.1:6060/orion" }, "attrsFormat": "legacy" }, "expires": "2019-08-01T09:31:07.617815Z" }

Response:

time=Thursday 01 Aug 09:23:40 2019.049Z | lvl=INFO | corr=0c65f6e6-b43e-11e9-9b54-0242ac160020 | trans=1564577919-668-00000000152 | from=192.168.1.1 | srv=<none> | subsrv=<none> | comp=Orion | op=logMsg.h[1844]:lmTransactionStart | msg=Starting transaction from 192.168.1.1:59634/v2/subscriptions/5d42ae11b1c943eb7f5b62c5,

time=Thursday 01 Aug 09:23:40 2019.050Z | lvl=INFO | corr=0c65f6e6-b43e-11e9-9b54-0242ac160020 | trans=1564577919-668-00000000152 | from=192.168.1.1 | srv=<none> | subsrv=<none> | comp=Orion | op=connectionOperations.cpp[307]:collectionFindOne | msg=Database Operation Successful (findOne: { _id: ObjectId('5d42ae11b1c943eb7f5b62c5') }),

time=Thursday 01 Aug 09:23:40 2019.050Z | lvl=ERROR | corr=0c65f6e6-b43e-11e9-9b54-0242ac160020 | trans=1564577919-668-00000000152 | from=192.168.1.1 | srv=<none> | subsrv=<none> | comp=Orion | op=safeMongo.cpp[129]:getStringField | msg=Runtime Error (string field 'lastFailureReason' is missing in BSONObj <{ _id: ObjectId('5d42ae11b1c943eb7f5b62c5'), expiration: 1564650678, reference: "http://192.168.1.1:6060/orion", custom: false, throttling: 0, servicePath: "/#", status: "active", entities: [ { id: ".*", isPattern: "true", type: "Output", isTypePattern: false } ], attrs: [], metadata: [], blacklist: false, conditions: [], lastFailure: 0, lastSuccess: 0, expression: { q: "", mq: "", geometry: "", coords: "", georel: "" }, format: "JSON" }> from caller setLastFailure:546),

time=Thursday 01 Aug 09:23:40 2019.050Z | lvl=ERROR | corr=0c65f6e6-b43e-11e9-9b54-0242ac160020 | trans=1564577919-668-00000000152 | from=192.168.1.1 | srv=<none> | subsrv=<none> | comp=Orion | op=safeMongo.cpp[260]:getIntOrLongFieldAsLong | msg=Runtime Error (int/long field 'lastSuccessCode' is missing in BSONObj <{ _id: ObjectId('5d42ae11b1c943eb7f5b62c5'), expiration: 1564650678, reference: "http://192.168.1.1:6060/orion", custom: false, throttling: 0, servicePath: "/#", status: "active", entities: [ { id: ".*", isPattern: "true", type: "Output", isTypePattern: false } ], attrs: [], metadata: [], blacklist: false, conditions: [], lastFailure: 0, lastSuccess: 0, expression: { q: "", mq: "", geometry: "", coords: "", georel: "" }, format: "JSON" }> from caller setLastSuccess:570),

time=Thursday 01 Aug 09:23:40 2019.050Z | lvl=INFO | corr=0c65f6e6-b43e-11e9-9b54-0242ac160020 | trans=1564577919-668-00000000152 | from=192.168.1.1 | srv=<none> | subsrv=<none> | comp=Orion | op=connectionOperations.cpp[449]:collectionUpdate | msg=Database Operation Successful (update: <{ _id: ObjectId('5d42ae11b1c943eb7f5b62c5') }, { expiration: 1564650678, reference: "http://192.168.1.1:6060/orion", custom: false, throttling: 0, servicePath: "/#", status: "active", entities: [ { id: ".*", isPattern: "true", type: "Output", isTypePattern: false } ], attrs: [], metadata: [], blacklist: false, conditions: [], lastFailure: 0, lastSuccess: 0, expression: { q: "", mq: "", geometry: "", coords: "", georel: "" }, format: "JSON" }>),

time=Thursday 01 Aug 09:23:40 2019.050Z | lvl=INFO | corr=0c65f6e6-b43e-11e9-9b54-0242ac160020 | trans=1564577919-668-00000000152 | from=192.168.1.1 | srv=<none> | subsrv=<none> | comp=Orion | op=logMsg.h[1874]:lmTransactionEnd | msg=Transaction ended
fgalan commented 5 years ago

Thanks for the report!

Fixed in PR https://github.com/telefonicaid/fiware-orion/pull/3532