Skip to content

IoT Job removes null value key pairs from the job document upon receipt #597

Closed as not planned
@AbbasAlibhaiER

Description

@AbbasAlibhaiER

Describe the bug

Hi!

I am working with aws-iot-device-sdk-python-v2, specifically the python script in the samples called jobs.py. When I trigger a remote action from my local device using the AWS CLI, with the below job document, it does not seem to be received by jobs.py in the same way, omitting key-value pairs with a null value. Below is an example of the job document (in json format) I would send:

{
    "steps": [
      {
        "action": "addConfigs",
        "configurations": {
          "thingamajig": [
            {
              "thingamajigType": "thingy",
              "thingamajigtIP": "192.168.1.212",
              "thingamajigPort": 3000,
              "thingamajigPort": true,
              "mainProgram": null,
              "additionalProgram": null,
              "robotPort": null,
              "robotNumber": null,
            }
          ]
        }
      }
    ]
  }

But this would be the job document jobs.py would receive:

{
   "steps": [
     {
       "action": "addConfigs",
       "configurations": {
         "thingamajig": [
           {
             "thingamajigType": "thingy",
             "thingamajigtIP": "192.168.0.123",
             "thingamajigPort": 3000,
             "thingamajigPort": True,
           }
         ]
       }
     }
   ]
 }

I can confirm on the AWS IoT core console that the job document was correctly sent by my device as the job document present within the remote action job matches the original json.

Any support on this issue would be helpful as we want to automate a system which can receive null value key-pairs as well. Thanks!

Regression Issue

  • Select this option if this issue appears to be a regression.

Expected Behavior

Send and receive json as below with null values (since it it python, these could be changed to None as null is not a python variable definition.
Send job document as below:

{
    "steps": [
      {
        "action": "addConfigs",
        "configurations": {
          "thingamajig": [
            {
              "thingamajigType": "thingy",
              "thingamajigtIP": "192.168.1.212",
              "thingamajigPort": 3000,
              "thingamajigPort": true,
              "mainProgram": null,
              "additionalProgram": null,
              "robotPort": null,
              "robotNumber": null,
            }
          ]
        }
      }
    ]
  }

Recieve job document as below:

{
    "steps": [
      {
        "action": "addConfigs",
        "configurations": {
          "thingamajig": [
            {
              "thingamajigType": "thingy",
              "thingamajigtIP": "192.168.1.212",
              "thingamajigPort": 3000,
              "thingamajigPort": True,
              "mainProgram": None,
              "additionalProgram": None,
              "robotPort": None,
              "robotNumber": None,
            }
          ]
        }
      }
    ]
  }

Current Behavior

When I trigger a remote action from my local device using the AWS CLI, with the below job document, it does not seem to be received by jobs.py in the same way, omitting key-value pairs with a null value. Below is an example of the job document (in json format) I would send:

{
    "steps": [
      {
        "action": "addConfigs",
        "configurations": {
          "thingamajig": [
            {
              "thingamajigType": "thingy",
              "thingamajigtIP": "192.168.1.212",
              "thingamajigPort": 3000,
              "thingamajigPort": true,
              "mainProgram": null,
              "additionalProgram": null,
              "robotPort": null,
              "robotNumber": null,
            }
          ]
        }
      }
    ]
  }

But this would be the job document jobs.py would receive:

{
   "steps": [
     {
       "action": "addConfigs",
       "configurations": {
         "thingamajig": [
           {
             "thingamajigType": "thingy",
             "thingamajigtIP": "192.168.0.123",
             "thingamajigPort": 3000,
             "thingamajigPort": True,
           }
         ]
       }
     }
   ]
 }

Reproduction Steps

Send a job document as below and receive it with jobs.py:

{
    "steps": [
      {
        "action": "addConfigs",
        "configurations": {
          "thingamajig": [
            {
              "thingamajigType": "thingy",
              "thingamajigtIP": "192.168.1.212",
              "thingamajigPort": 3000,
              "thingamajigPort": true,
              "mainProgram": null,
              "additionalProgram": null,
              "robotPort": null,
              "robotNumber": null,
            }
          ]
        }
      }
    ]
  }

Possible Solution

I'm taking a shot in the dark here but whatever we are using to convert the json job document to be python readable needs to account for null values

Additional Information/Context

No response

SDK version used

v2 I think

Environment details (OS name and version, etc.)

Ubuntu 20.04

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions