Skip to content

status field in services messages is ignored if pid field is not an integer #3128

@reubenmiller

Description

@reubenmiller

Describe the bug

In #2919, the parsing of the service status messages added the pid field (as a Option<u32>), however adding this field made the parsing of the message had the side effect from rejecting the whole message if the pid field was not in the expected format. In previous thin-edge.io versions, the pid field could of been any data type, where as thin-edge.io 1.3.0 it MUST be left out or an uint.

This chang causes a breaking change for service status payloads that, which results in the status property being ignored and defaulting to unknown (due to the parsing error on the pid field). From a logic point of view, the mapper should not care about the pid field as it is not using the the information in the mapping, so it should not affect the parsing of the service status field.

For example, the publishing the following message with the pid set as a string, will result in the outgoing message to Cumulocity IoT, will use the status=unknown on the outgoing message.

tedge mqtt pub te/device/main/service/my-service/status/health '{"status": "up", "pid": "21037"}'

Message published to Cumulocity IoT

[c8y/s/us] 102,rmi-macos:device:main:service:my-service,service,my-service,unknown

To Reproduce

  1. On the device, open a new console and subscribe to the outgoing c8y cloud messages

    tedge mqtt sub 'c8y/s/us'
  2. Open a new console, publish the following message

    tedge mqtt pub te/device/main/service/my-service/status/health '{"status": "up", "pid": "21037"}'
  3. Observe the outgoing cloud message in the first console, it will show the unknown value (below is an example of the message)

    [c8y/s/us] 102,rmi-macos:device:main:service:my-service,service,my-service,unknown

Expected behavior

The tedge-mapper should only try to parse the information that is required for the mapping of the service message. At this point in time the pid field is not used by the mapper, so the value of it should not affect the parsing of the status field.

Screenshots

Environment (please complete the following information):

  • OS [incl. version]: any
  • Hardware [incl. revision]: any
  • System-Architecture [e.g. result of "uname -a"]: any
  • thin-edge.io version [e.g. 0.1.0]: 1.3.0

Additional context

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions