pingidentity / scim2

The UnboundID SCIM 2.0 SDK for Java
181 stars 74 forks source link

JsonUtils.replaceValue fails when given null value #118

Closed hauntingEcho closed 5 months ago

hauntingEcho commented 5 years ago

Describe the bug When a function which calls JsonUtils.replaceValue is given a null, an NullPointerException is thrown by UpdatingNodeVisitor when attempting to deepCopy() that null.

To Reproduce construct a GenericScimResource x and call x.setSchemaUrns(null).

Expected behavior the Schemas element is removed from the resource

Additional context This can be necessary to construct a PATCH operation on an overall Group object, in which you don't want to edit the schema URNs.

kqarryzada commented 5 months ago

In the next release of the SCIM SDK, we will have a @NotNull annotation on the inputs of both com.unboundid.scim2.common.ScimResource#setSchemaUrns methods, which will allow the library to explicitly declare that this field should not be null. As you've noted, this was an expectation that was not explicitly made before.

I can't think of a situation where setting this to null would be desirable. In RFC 7644 Section 3.5.2.1, an example group update with the PATCH operation is provided where the schema of the resource is urn:ietf:params:scim:api:messages:2.0:PatchOp, which makes sense because the JSON data represents a SCIM PatchOp. The schema URN of the group resource will not be touched by the update because the schemas attribute is not mentioned in the Operations list.

If I'm misunderstanding the context and there's a better example that highlights the need for this, then please feel free to provide more details.