Azure / iotedge

The IoT Edge OSS project
MIT License
1.46k stars 460 forks source link

custom module twin desired values get mixed #7374

Closed tervoju closed 1 month ago

tervoju commented 2 months ago

I have custom module implemented with python. trying to use module twin desired properties from azure portal. Somehow module twin desired properties got mixed. I put simply this

 "desired": {
                "values": {
                    "value1": "1",
                    "value2": "2",
                    "value3": "3"
                }
            },...

somehow it got this and I cannot fix it:

  "desired": {
        "$metadata": {
            "$lastUpdated": "2024-09-24T05:46:21.1086112Z",
            "$lastUpdatedVersion": 10,
            "desired": {
                "$lastUpdated": "2024-09-23T13:55:29.6675232Z",
                "$lastUpdatedVersion": 2,
                "values": {
                    "$lastUpdated": "2024-09-23T13:55:29.6675232Z",
                    "$lastUpdatedVersion": 2,
                    "value1": {
                        "$lastUpdated": "2024-09-23T13:55:29.6675232Z",
                        "$lastUpdatedVersion": 2
                    },
                    "value2": {
                        "$lastUpdated": "2024-09-23T13:55:29.6675232Z",
                        "$lastUpdatedVersion": 2
                    },
                    "value3": {
                        "$lastUpdated": "2024-09-23T13:55:29.6675232Z",
                        "$lastUpdatedVersion": 2
                    }
                }
            },
            "value1": {
                "$lastUpdated": "2024-09-24T05:44:42.7953719Z",
                "$lastUpdatedVersion": 9
            },
            "value2": {
                "$lastUpdated": "2024-09-24T05:44:42.7953719Z",
                "$lastUpdatedVersion": 9
            },
            "value3": {
                "$lastUpdated": "2024-09-24T05:44:42.7953719Z",
                "$lastUpdatedVersion": 9
            },
            "values": {
                "$lastUpdated": "2024-09-24T05:46:21.1086112Z",
                "$lastUpdatedVersion": 10,
                "value1": {
                    "$lastUpdated": "2024-09-24T05:46:21.1086112Z",
                    "$lastUpdatedVersion": 10
                },
                "value2": {
                    "$lastUpdated": "2024-09-24T05:46:21.1086112Z",
                    "$lastUpdatedVersion": 10
                },
                "value3": {
                    "$lastUpdated": "2024-09-24T05:46:21.1086112Z",
                    "$lastUpdatedVersion": 10
                }
            }
        },
        "$version": 10,
        "desired": {
            "values": {
                "value1": "1",
                "value2": "2",
                "value3": "3"
            }
        },
        "value1": "1",
        "value2": "2",
        "value3": "3",
        "values": {
            "value1": "1",
            "value2": "2",
            "value3": "3"
        }
    },

Expected Behavior

Tell us what should happen: simple twin values are there and not multiple times.

Current Behavior

Tell us what happens instead of the expected behavior: values are there multiple times and I cannot fix it

Steps to Reproduce

Provide a detailed set of steps to reproduce the bug.

  1. create custom module
  2. fiddle the module twin values in the portal
  3. desired properties got mixed
  4. cannot fix the values anymore

Context (Environment)

Output of iotedge check

not relevant - this portal issue



### Device Information
not relevant
ryanwinter commented 1 month ago

hi @tervoju,

To remove properties you don't want, you can set them to null as outlined in the docs: https://learn.microsoft.com/azure/iot-hub/iot-hub-devguide-device-twins#back-end-operations