Azure / azure-iot-explorer

Cross-platform UI for interacting with devices attached to Azure IoT Hub. This tool is meant for learning and testing, not for production environment.
MIT License
224 stars 73 forks source link

[BUG] IoT PnP: Empty string not allowed in "mapValue": { "name": "xyz", "schema": "string"} #505

Closed Salazander closed 1 year ago

Salazander commented 2 years ago

Describe the bug I'm working on the DTDL definition of a new OSConfig module. Here's the work in progress: https://github.com/Salazander/iot-plugandplay-models/blob/main/dtmi/osconfig/pmc-1.json I tried to set a "mapValue" of type "string" to "" (empty string) using Azure IoT Explorer, but the input validation rejects empty strings. image

Since setting an empty string is overloaded with a very specific meaning in our case, setting "" as mapValue is valid from our point of view. Is there anything in the docs that suggest that empty strings are invalid? https://github.com/Azure/opendigitaltwins-dtdl/blob/master/DTDL/v2/dtdlv2.md#map

To Reproduce Steps to reproduce the behavior:

  1. Add a writeable Property with a map to any PnP Model that gets loaded from a local folder

    {
    "@context": "dtmi:dtdl:context;2",
    "@id": "dtmi:osconfig:pmc;1",
    "@type": "Interface",
    "displayName": "Repro",
    "description": "Repro",
    "contents": [
    {
      "@type": "Property",
      "name": "desiredState",
      "schema": {
        "@type": "Object",
        "fields": [
          {
            "name": "sources",
            "schema": {
              "@type": "Map",
              "mapKey": {
                "name": "id",
                "schema": "string"
              },
              "mapValue": {
                "name": "entry",
                "schema": "string"
              }
            }
          }
        ]
      },
      "writable": true
    }
    ]
    }
  2. Open Device -> Module identities > IoT Plug and Play components -> Properties (writable)

  3. Try to set an empty string as input parameter for entry

  4. -> Input validation fails

Expected behavior An empty string "" is a valid input parameter for mapValues of type "string"

Screenshots image Note the unrelated validation issue with numbers.

Desktop (please complete the following information):

YingXue commented 2 years ago

Hi @Salazander The asterisk start beside 'entry' does indicate this is a required property. At the time everything is a required a property, so that's what this tool is enforcing. I remember there has been discussions around DTDL languages support optional property before, unfortunately we are lacking bandwidth to update the tool to keep up the latest. Will keep this item in our backlog, and when the time comes we will update the tool to be compliant with DTDL v3

YingXue commented 1 year ago

Fixed released in https://github.com/Azure/azure-iot-explorer/releases/tag/v0.15.8. Closing.