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

Patch phone numbers triggers object null reference exception #60

Open
GuidoNeele opened this issue Jul 13, 2021 · 0 comments · May be fixed by #51 or #48
Open

Patch phone numbers triggers object null reference exception #60

GuidoNeele opened this issue Jul 13, 2021 · 0 comments · May be fixed by #51 or #48
Labels
bug Something isn't working

Comments

@GuidoNeele
Copy link

GuidoNeele commented Jul 13, 2021

When an existing user is patched with a phone number that's not already in the list a null reference exception will occur.

if (user.PhoneNumbers != null)
{
phoneNumberExisting =
phoneNumber =
user
.PhoneNumbers
.SingleOrDefault(
(PhoneNumber item) =>
string.Equals(subAttribute.ComparisonValue, item.ItemType, StringComparison.Ordinal));
}

This checks if the phone number already exists, if not then the SingleOrDefault() will assign null to phoneNumber.

A few lines later (after retrieving the value of the patch operation) the phone number is updated while phoneNumber is null.

The same structure is used for patching email adresses, roles, addresses etc.

The patch body looked like this:

{
    "schemas": [
        "urn:ietf:params:scim:api:messages:2.0:PatchOp"
    ],
    "Operations": [
        {
            "op": "Add",
            "path": "phoneNumbers[type eq \"work\"].value",
            "value": "1120"
        }
    ]
}

Phone numbers did exist but not of type 'work'.

@marcusca10 marcusca10 added the bug Something isn't working label Jan 19, 2022
@marcusca10 marcusca10 linked a pull request Jan 19, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
2 participants