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

Problems with Null Values in a custom field #185

Closed
jprettyman opened this issue Sep 15, 2020 · 3 comments
Closed

Problems with Null Values in a custom field #185

jprettyman opened this issue Sep 15, 2020 · 3 comments
Labels
documentation Should be reflected in Documentation or FAQ update good first issue Good for newcomers question Further information is requested wontfix This will not be worked on
Milestone

Comments

@jprettyman
Copy link

I have a custom field and want to set the value for children to the same as self. In some cases, the self value is null. This causes a save problem.

[2020-09-15 14:07:11Z] [{"Code":400,"Headers":{"Content-Type":"application/json; charset=utf-8"},"Body":"{\"count\":1,\"value\":{\"Message\":\"Value cannot be null.\"}}"},{"Code":400,"Headers":{"Content-Type":"application/json; charset=utf-8"},"Body":"{\"count\":1,\"value\":{\"Message\":\"Value cannot be null.\"}}"},{"Code":400,"Headers":{"Content-Type":"application/json; charset=utf-8"},"Body":"{\"count\":1,\"value\":{\"Message\":\"Value cannot be null.\"}}"}]
[2020-09-15 14:07:11Z] Save failed: {"count":1,"value":{"Message":"Value cannot be null."}}

If I wrap it in a statement, things work OK

if (child["MyCo.Common.MyField"] != null ) { child["MyCo.Common.MyField"] = self["MyCo.Common.MyField"]; }

if I use it direct, I get the message above if the self value is null.

child["MyCo.Common.MyField"] = self["MyCo.Common.MyField"];

Is there a clean way of handling null values without wrapping fields in an if statement?

@giuliov giuliov added documentation Should be reflected in Documentation or FAQ update good first issue Good for newcomers question Further information is requested labels Sep 19, 2020
@giuliov
Copy link
Member

giuliov commented Sep 19, 2020

What happens behind the scene
Azure DevOps returns only fields with a value. To prevent exceptions, when a field is read, the private GetFieldValue method checks if there is a value, otherwise it returns a default value for the field type. Custom fields type is object unless you use the public GetFieldValue method or a cast.
This means that a missing custom field has value null.
When SetFieldValue is called from the assignment operator, it records an change operation with the new value.
When the Rule completes, all change operations are sent to Azure DevOps.

Solutions

  1. Guard the assignment with an if != null. This is a bit cumbersome, but can implemented within a Rule. This what you used
  2. Change SetFieldValue behaviour to skip null assignments.
  3. Change SetFieldValue behaviour to use a remove operation when value is null. This will remove any value on the target.

I am leaning on the latter, but I would like some feedback from you (and @jessehouwing)

@giuliov giuliov added this to the 1.0.x milestone Sep 19, 2020
@jprettyman
Copy link
Author

After reviewing your response, I agree that removing the value for Nulls would be the most appropriate action. If the user keys in valA = valB; and valB is null, make valA null. the only way to do this is to initiate a remove action within the SetFieldValue.

@stale
Copy link

stale bot commented Nov 20, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix This will not be worked on label Nov 20, 2020
@stale stale bot closed this as completed Nov 27, 2020
giuliov added a commit that referenced this issue Dec 12, 2020
* initial set of Terraform script to create a dev VM in Azure

Azure DevOps Server included

* address #185 by removing field when set to null value

* address sonar issues

* Retry after Http 429 using Polly, address #71

* Removed annoying messages about new version check

* Deprecation notice for resourceGroup option

* fix IDataProtectionProvider.CreateProtector purpose string

Improve #192

* New update.mappings command

* final version of update.mappings

Missing: tests & doc

* added integration test for new update.mappings command

* Fix impersonation not triggering
when the rule updates the same work item
that was changed by the user.

* bump GitVersion

* Harden Azure resource (#225)

* Squashed commit of the following:

commit bab34f1b5b93b3d86dca7e2f5c6c25203e33ea15
Merge: c3b4ad1 423f77f
Author: Giulio Vian <giuliovdev@hotmail.com>
Date:   Sat Dec 12 16:21:34 2020 +0100

    Merge remote-tracking branch 'origin/dependabot/nuget/src/Microsoft.Extensions.Hosting-5.0.0' into uppers2

    # Conflicts:
    #	src/aggregator-host/aggregator-host.csproj

commit c3b4ad131ef295eef73c08103f023fae2c6df8c5
Merge: 1b4407e 88e8bcc
Author: Giulio Vian <giuliovdev@hotmail.com>
Date:   Sat Dec 12 16:21:02 2020 +0100

    Merge remote-tracking branch 'origin/dependabot/nuget/src/Microsoft.Azure.WebJobs-3.0.23' into uppers2

    # Conflicts:
    #	src/aggregator-function/aggregator-function.csproj

commit 1b4407eac1eb7bc46d3782285831694868ac3179
Merge: 21523a1 abd25f0
Author: Giulio Vian <giuliovdev@hotmail.com>
Date:   Sat Dec 12 16:20:21 2020 +0100

    Merge remote-tracking branch 'origin/dependabot/nuget/src/Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel-2.16.0' into uppers2

    # Conflicts:
    #	src/aggregator-cli/aggregator-cli.csproj

commit 21523a1e831046a7e8dc6186553f7bcf28e2ab69
Merge: 2ae99ac 86efb3f
Author: Giulio Vian <giuliovdev@hotmail.com>
Date:   Sat Dec 12 16:19:38 2020 +0100

    Merge remote-tracking branch 'origin/dependabot/nuget/src/Microsoft.Extensions.Configuration.EnvironmentVariables-5.0.0' into uppers2

    # Conflicts:
    #	src/aggregator-function/aggregator-function.csproj
    #	src/aggregator-webshared/aggregator-webshared.csproj

commit 2ae99ac2de92366b051d31f0b25d5b848902dba6
Merge: c53448c 44982ac
Author: Giulio Vian <giuliovdev@hotmail.com>
Date:   Sat Dec 12 16:17:45 2020 +0100

    Merge remote-tracking branch 'origin/dependabot/nuget/src/Microsoft.Extensions.Configuration.Json-5.0.0' into uppers2

    # Conflicts:
    #	src/aggregator-function/aggregator-function.csproj
    #	src/aggregator-webshared/aggregator-webshared.csproj

commit c53448cf7ee1e97801dfb424480dc8eaeda08ff2
Merge: cf22760 ce43d27
Author: Giulio Vian <giuliovdev@hotmail.com>
Date:   Sat Dec 12 16:16:40 2020 +0100

    Merge remote-tracking branch 'origin/dependabot/nuget/src/Microsoft.Extensions.Configuration-5.0.0' into uppers2

    # Conflicts:
    #	src/aggregator-shared/aggregator-shared.csproj

commit cf227608b2b49893d25fd3ce468907e0f82b84dc
Merge: ab3ed38 813cd0e
Author: Giulio Vian <giuliovdev@hotmail.com>
Date:   Sat Dec 12 16:16:02 2020 +0100

    Merge remote-tracking branch 'origin/dependabot/nuget/src/Microsoft.Extensions.Configuration.FileExtensions-5.0.0' into uppers2

commit ab3ed3840891cb17e969e5a69e37cf8de9d8b79d
Merge: b3d1656 a668958
Author: Giulio Vian <giuliovdev@hotmail.com>
Date:   Sat Dec 12 16:15:40 2020 +0100

    Merge remote-tracking branch 'origin/dependabot/nuget/src/Microsoft.Azure.Management.ResourceManager.Fluent-1.36.0' into uppers2

    # Conflicts:
    #	src/aggregator-cli/aggregator-cli.csproj

commit b3d1656c861e1fb08412cc9e5c405c1d5118bb57
Merge: b324ef9 fc2e7a6
Author: Giulio Vian <giuliovdev@hotmail.com>
Date:   Sat Dec 12 16:14:34 2020 +0100

    Merge remote-tracking branch 'origin/dependabot/nuget/src/Microsoft.Azure.Management.Fluent-1.36.0' into uppers2

    # Conflicts:
    #	src/aggregator-cli/aggregator-cli.csproj
    #	src/aggregator-shared/aggregator-shared.csproj

commit b324ef9d783f9811547c85d52d10307293c2db72
Merge: 6c59d10 048b822
Author: Giulio Vian <giuliovdev@hotmail.com>
Date:   Sat Dec 12 16:12:41 2020 +0100

    Merge remote-tracking branch 'origin/dependabot/nuget/src/Microsoft.ApplicationInsights-2.16.0' into uppers2

commit 6c59d10380d1db2ee75327d71da5a46bfea0cf83
Merge: 742a432 8258ac0
Author: Giulio Vian <giuliovdev@hotmail.com>
Date:   Sat Dec 12 16:12:30 2020 +0100

    Merge remote-tracking branch 'origin/dependabot/nuget/src/Microsoft.AspNetCore.DataProtection-5.0.0' into uppers2

commit 742a4320d9a8544d6445eac9af7b1f7f7da9fb19
Merge: 6c5d1a6 5374ab5
Author: Giulio Vian <giuliovdev@hotmail.com>
Date:   Sat Dec 12 16:12:20 2020 +0100

    Merge remote-tracking branch 'origin/dependabot/nuget/src/System.Text.Json-5.0.0' into uppers2

    # Conflicts:
    #	src/unittests-function/unittests-function.csproj

commit 6c5d1a65f94c9967e19d93e94dc8f999a3c9a84b
Merge: 7f38201 4605ea2
Author: Giulio Vian <giuliovdev@hotmail.com>
Date:   Sat Dec 12 16:05:58 2020 +0100

    Merge remote-tracking branch 'origin/dependabot/nuget/src/NSubstitute.Analyzers.CSharp-1.0.14' into uppers

commit 7f38201a9e829e948be3b3b15d88b7f627a8f037
Merge: dca80ab 8bcd3e7
Author: Giulio Vian <giuliovdev@hotmail.com>
Date:   Sat Dec 12 16:05:44 2020 +0100

    Merge remote-tracking branch 'origin/dependabot/nuget/src/Microsoft.NET.Test.Sdk-16.8.0' into uppers

commit dca80abcb3f522313b3b5e0bcea21bea78561193
Merge: e4b94c7 dfa39b0
Author: Giulio Vian <giuliovdev@hotmail.com>
Date:   Sat Dec 12 16:05:24 2020 +0100

    Merge remote-tracking branch 'origin/dependabot/nuget/src/Microsoft.Extensions.DependencyInjection-5.0.0' into uppers

commit e4b94c7
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Tue Dec 1 05:28:16 2020 +0000

    Bump Microsoft.CodeAnalysis.Scripting from 3.7.0 to 3.8.0 in /src

    Bumps [Microsoft.CodeAnalysis.Scripting](https://github.com/dotnet/roslyn) from 3.7.0 to 3.8.0.
    - [Release notes](https://github.com/dotnet/roslyn/releases)
    - [Changelog](https://github.com/dotnet/roslyn/blob/master/docs/Breaking%20API%20Changes.md)
    - [Commits](https://github.com/dotnet/roslyn/commits)

    Signed-off-by: dependabot[bot] <support@github.com>

commit 5374ab5
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Tue Dec 1 05:27:50 2020 +0000

    Bump System.Text.Json from 4.7.2 to 5.0.0 in /src

    Bumps [System.Text.Json](https://github.com/dotnet/runtime) from 4.7.2 to 5.0.0.
    - [Release notes](https://github.com/dotnet/runtime/releases)
    - [Commits](https://github.com/dotnet/runtime/commits)

    Signed-off-by: dependabot[bot] <support@github.com>

commit 8258ac0
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Tue Dec 1 05:27:16 2020 +0000

    Bump Microsoft.AspNetCore.DataProtection from 3.1.8 to 5.0.0 in /src

    Bumps [Microsoft.AspNetCore.DataProtection](https://github.com/dotnet/aspnetcore) from 3.1.8 to 5.0.0.
    - [Release notes](https://github.com/dotnet/aspnetcore/releases)
    - [Commits](dotnet/aspnetcore@v3.1.8...v5.0.0)

    Signed-off-by: dependabot[bot] <support@github.com>

commit 048b822
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Tue Dec 1 05:27:07 2020 +0000

    Bump Microsoft.ApplicationInsights from 2.14.0 to 2.16.0 in /src

    Bumps [Microsoft.ApplicationInsights](https://github.com/Microsoft/ApplicationInsights-dotnet) from 2.14.0 to 2.16.0.
    - [Release notes](https://github.com/Microsoft/ApplicationInsights-dotnet/releases)
    - [Changelog](https://github.com/microsoft/ApplicationInsights-dotnet/blob/develop/CHANGELOG.md)
    - [Commits](microsoft/ApplicationInsights-dotnet@2.14.0...2.16.0)

    Signed-off-by: dependabot[bot] <support@github.com>

commit 813cd0e
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Tue Dec 1 05:27:05 2020 +0000

    Bump Microsoft.Extensions.Configuration.FileExtensions in /src

    Bumps [Microsoft.Extensions.Configuration.FileExtensions](https://github.com/dotnet/runtime) from 3.1.8 to 5.0.0.
    - [Release notes](https://github.com/dotnet/runtime/releases)
    - [Commits](https://github.com/dotnet/runtime/commits)

    Signed-off-by: dependabot[bot] <support@github.com>

commit fc2e7a6
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Tue Dec 1 05:27:05 2020 +0000

    Bump Microsoft.Azure.Management.Fluent from 1.34.0 to 1.36.0 in /src

    Bumps [Microsoft.Azure.Management.Fluent](https://github.com/Azure/azure-libraries-for-net) from 1.34.0 to 1.36.0.
    - [Release notes](https://github.com/Azure/azure-libraries-for-net/releases)
    - [Commits](Azure/azure-libraries-for-net@Fluent-v1.34.0...Fluent-v1.36.0)

    Signed-off-by: dependabot[bot] <support@github.com>

commit ce43d27
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Tue Dec 1 05:27:04 2020 +0000

    Bump Microsoft.Extensions.Configuration from 3.1.8 to 5.0.0 in /src

    Bumps [Microsoft.Extensions.Configuration](https://github.com/dotnet/runtime) from 3.1.8 to 5.0.0.
    - [Release notes](https://github.com/dotnet/runtime/releases)
    - [Commits](https://github.com/dotnet/runtime/commits)

    Signed-off-by: dependabot[bot] <support@github.com>

commit a668958
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Tue Dec 1 05:27:04 2020 +0000

    Bump Microsoft.Azure.Management.ResourceManager.Fluent in /src

    Bumps [Microsoft.Azure.Management.ResourceManager.Fluent](https://github.com/Azure/azure-libraries-for-net) from 1.34.0 to 1.36.0.
    - [Release notes](https://github.com/Azure/azure-libraries-for-net/releases)
    - [Commits](Azure/azure-libraries-for-net@Fluent-v1.34.0...Fluent-v1.36.0)

    Signed-off-by: dependabot[bot] <support@github.com>

commit 8bcd3e7
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Tue Dec 1 05:27:04 2020 +0000

    Bump Microsoft.NET.Test.Sdk from 16.7.1 to 16.8.0 in /src

    Bumps [Microsoft.NET.Test.Sdk](https://github.com/microsoft/vstest) from 16.7.1 to 16.8.0.
    - [Release notes](https://github.com/microsoft/vstest/releases)
    - [Commits](microsoft/vstest@v16.7.1...v16.8.0)

    Signed-off-by: dependabot[bot] <support@github.com>

commit dfa39b0
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Tue Dec 1 05:27:04 2020 +0000

    Bump Microsoft.Extensions.DependencyInjection in /src

    Bumps [Microsoft.Extensions.DependencyInjection](https://github.com/dotnet/runtime) from 3.1.8 to 5.0.0.
    - [Release notes](https://github.com/dotnet/runtime/releases)
    - [Commits](https://github.com/dotnet/runtime/commits)

    Signed-off-by: dependabot[bot] <support@github.com>

commit 4605ea2
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Tue Dec 1 05:27:03 2020 +0000

    Bump NSubstitute.Analyzers.CSharp from 1.0.13 to 1.0.14 in /src

    Bumps [NSubstitute.Analyzers.CSharp](https://github.com/nsubstitute/NSubstitute.Analyzers) from 1.0.13 to 1.0.14.
    - [Release notes](https://github.com/nsubstitute/NSubstitute.Analyzers/releases)
    - [Changelog](https://github.com/nsubstitute/NSubstitute.Analyzers/blob/1.0.14/ReleaseNotes.md)
    - [Commits](nsubstitute/NSubstitute.Analyzers@1.0.13...1.0.14)

    Signed-off-by: dependabot[bot] <support@github.com>

commit 44982ac
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Tue Dec 1 05:27:02 2020 +0000

    Bump Microsoft.Extensions.Configuration.Json from 3.1.8 to 5.0.0 in /src

    Bumps [Microsoft.Extensions.Configuration.Json](https://github.com/dotnet/runtime) from 3.1.8 to 5.0.0.
    - [Release notes](https://github.com/dotnet/runtime/releases)
    - [Commits](https://github.com/dotnet/runtime/commits)

    Signed-off-by: dependabot[bot] <support@github.com>

commit 88e8bcc
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Tue Dec 1 05:27:01 2020 +0000

    Bump Microsoft.Azure.WebJobs from 3.0.18 to 3.0.23 in /src

    Bumps [Microsoft.Azure.WebJobs](https://github.com/Azure/azure-webjobs-sdk) from 3.0.18 to 3.0.23.
    - [Release notes](https://github.com/Azure/azure-webjobs-sdk/releases)
    - [Commits](Azure/azure-webjobs-sdk@v3.0.18...v3.0.23)

    Signed-off-by: dependabot[bot] <support@github.com>

commit abd25f0
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Tue Dec 1 05:27:01 2020 +0000

    Bump Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel

    Bumps [Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel](https://github.com/Microsoft/ApplicationInsights-dotnet) from 2.14.0 to 2.16.0.
    - [Release notes](https://github.com/Microsoft/ApplicationInsights-dotnet/releases)
    - [Changelog](https://github.com/microsoft/ApplicationInsights-dotnet/blob/develop/CHANGELOG.md)
    - [Commits](microsoft/ApplicationInsights-dotnet@2.14.0...2.16.0)

    Signed-off-by: dependabot[bot] <support@github.com>

commit 86efb3f
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Tue Dec 1 05:27:01 2020 +0000

    Bump Microsoft.Extensions.Configuration.EnvironmentVariables in /src

    Bumps [Microsoft.Extensions.Configuration.EnvironmentVariables](https://github.com/dotnet/runtime) from 3.1.8 to 5.0.0.
    - [Release notes](https://github.com/dotnet/runtime/releases)
    - [Commits](https://github.com/dotnet/runtime/commits)

    Signed-off-by: dependabot[bot] <support@github.com>

commit 423f77f
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Tue Dec 1 05:26:58 2020 +0000

    Bump Microsoft.Extensions.Hosting from 3.1.8 to 5.0.0 in /src

    Bumps [Microsoft.Extensions.Hosting](https://github.com/dotnet/runtime) from 3.1.8 to 5.0.0.
    - [Release notes](https://github.com/dotnet/runtime/releases)
    - [Commits](https://github.com/dotnet/runtime/commits)

    Signed-off-by: dependabot[bot] <support@github.com>

* Release notes

* stop using Dependabot

* clear warnings

Co-authored-by: Alexander Omelchuk <AOK@foss.dk>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Should be reflected in Documentation or FAQ update good first issue Good for newcomers question Further information is requested wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

2 participants