Captain-P-Goldfish / SCIM-SDK

a scim implementation as described in RFC7643 and RFC7644
https://github.com/Captain-P-Goldfish/SCIM/wiki
BSD 3-Clause "New" or "Revised" License
121 stars 38 forks source link

[Server] Patch request with invalid id causes Null Pointer Exception #661

Closed prthakre closed 3 months ago

prthakre commented 3 months ago

Sample code: https://github.com/Captain-P-Goldfish/SCIM-SDK/tree/1.23.0/samples/scim-sdk-springboot-example

>curl --location --globoff --request PATCH 'http://localhost:8080/scim/v2/Users/c631f2a8-b0d1-4bd8-834f-99ef810555531' -H "Content-Type: application/scim+json" -d \
'{
  "schemas": [
    "urn:ietf:params:scim:api:messages:2.0:PatchOp"
  ],
  "Operations": [
    {
      "op": "replace",
      "value": {
        "nickName": "user2"
      }
    }
  ]
}'

{
  "detail" : "An internal error has occurred.",
  "schemas" : [ "urn:ietf:params:scim:api:messages:2.0:Error" ],
  "status" : 500
}

Exception thrown by the sdk server:

Caused by: java.lang.NullPointerException: Cannot invoke "de.captaingoldfish.scim.sdk.common.resources.ResourceNode.toString()" because "this.patchedResource" is null
    at de.captaingoldfish.scim.sdk.server.patch.DefaultPatchOperationHandler.lambda$getOldResourceSupplier$0(DefaultPatchOperationHandler.java:112)
    at de.captaingoldfish.scim.sdk.server.endpoints.ResourceEndpointHandler.lambda$patchResource$24(ResourceEndpointHandler.java:1015)
    at de.captaingoldfish.scim.sdk.server.interceptor.NoopInterceptor.doAround(NoopInterceptor.java:21)
    at de.captaingoldfish.scim.sdk.server.endpoints.ResourceEndpointHandler.patchResource(ResourceEndpointHandler.java:1011)
    ... 42 more
prthakre commented 3 months ago

Need to throw ResourceNotFoundException if inMemoryMap.get(id); returns null.