Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting property to null does not always erase it #243

Closed
tiagoshibata opened this issue Nov 21, 2017 · 5 comments
Closed

Setting property to null does not always erase it #243

tiagoshibata opened this issue Nov 21, 2017 · 5 comments
Assignees
Labels
area-service Issue points to a problem in the service. bug Something isn't working. IoTSDK Tracks all IoT SDK issues across the board

Comments

@tiagoshibata
Copy link

  • OS and version used: Windows 10 Insider Preview (Version 10.0.17035 Build 17035)
  • SDK version used: 1.5.2

Description of the issue:

Setting a reported property to null should remove that property, as I understand from the docs. It doesn't in some situations.

Code sample exhibiting the issue:

using Microsoft.Azure.Devices.Client;
using Microsoft.Azure.Devices.Shared;
using System;
using System.Threading.Tasks;

namespace IotHubClient
{
    class Program
    {
        static void Main(string[] args)
        {
            MainAsync(args).GetAwaiter().GetResult();
        }

        static async Task MainAsync(string[] args)
        {
            var client = DeviceClient.CreateFromConnectionString("Connection string here");

            await client.UpdateReportedPropertiesAsync(new TwinCollection
            {
                ["a"] = null
            });

            await client.UpdateReportedPropertiesAsync(new TwinCollection
            {
                ["a"] = new TwinCollection
                {
                    ["b"] = null
                }
            });

            await client.UpdateReportedPropertiesAsync(new TwinCollection
            {
                ["a"] = new TwinCollection
                {
                    ["b"] = null
                }
            });
        }
    }
}

Use breakpoints and observe the device twin after each call. The first call will erase a from the document root as expected. The second call is buggy and creates object a with key b, containing null, instead of creating an empty object (I expect b to be removed). The third call (assigning null to a key containing null) works as expected (removing b). It seems like the issue only repros when creating a new object with null values.

Somewhat related to #86 .

This affects me when I want to remove keys (right now I would have to first check if the object nesting the key exists before trying to remove it).

@tiagoshibata
Copy link
Author

It repros in both reported and desired properties:

reported

desired

@tiagoshibata tiagoshibata changed the title Setting reported property to null does not always erase the property Setting property to null does not always erase the property Nov 22, 2017
@tiagoshibata tiagoshibata changed the title Setting property to null does not always erase the property Setting property to null does not always erase it Nov 22, 2017
@tameraw tameraw added the investigation-required Requires further investigation to root cause this. label Jan 17, 2018
@CIPop
Copy link
Member

CIPop commented Jan 22, 2018

Thanks for reporting @tiagoshibata !
We were able to repro the issue and now need to investigate to understand why this is happening.

@CIPop CIPop added bug Something isn't working. and removed investigation-required Requires further investigation to root cause this. labels Jan 22, 2018
@CIPop CIPop removed their assignment Jan 23, 2018
@zolvarga
Copy link
Contributor

zolvarga commented Mar 1, 2018

@tiagoshibata

Update: It is a server side issue and I reported to the service team.
I will update you with the timeline.

Best Regards,
Zoltan

@CIPop CIPop added the area-service Issue points to a problem in the service. label Mar 1, 2018
@zolvarga zolvarga self-assigned this Mar 1, 2018
@CIPop CIPop self-assigned this Jun 15, 2018
@sharmasejal sharmasejal added the IoTSDK Tracks all IoT SDK issues across the board label Mar 19, 2020
@timtay-microsoft
Copy link
Member

Closing this issue because it isn't an SDK bug. The tests we disabled while the bug got fixed have been re-enabled, so I don't see a reason to keep this issue open

@az-iot-builder-01
Copy link
Contributor

@tiagoshibata, @CIPop, thank you for your contribution to our open-sourced project! Please help us improve by filling out this 2-minute customer satisfaction survey

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-service Issue points to a problem in the service. bug Something isn't working. IoTSDK Tracks all IoT SDK issues across the board
Projects
None yet
Development

No branches or pull requests

7 participants