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

Patch for nonexistent user causes NPE - returns status 500 and logs exception with stack-trace #666

Closed ondrejzivotsky closed 3 months ago

ondrejzivotsky commented 3 months ago

Updating nonexistent user causes NullPointerException. In the log is full stack-trace of NPE. I would expect HTTP 404 is returned (like in the case of the GET call).

Request:

> curl --location --request PATCH 'http://localhost:8080/scim/v2/Users/nonexistent-user-id' --header 'Content-Type: application/scim+json' \
--data '{
    "schemas":["urn:ietf:params:scim:api:messages:2.0:PatchOp"],
    "Operations":[
        {
      "op": "replace",
      "path": "active",
      "value": false
    }
    ]
}'

Response:

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

Expected response:

{
  "detail" : "the 'User' resource with id 'nonexistent-user-id' does not exist",
  "schemas" : [ "urn:ietf:params:scim:api:messages:2.0:Error" ],
  "status" : 404
}