Skip to content

Exception when patch endpoint receives unexpected request format. #29

@rreinhardt9

Description

@rreinhardt9

When the PATCH endpoint (which is not complete or scim complaint yet) receives a request with a payload that is not supported yet, it intends to return a 422 and message like: "Invalid PATCH request. This PATCH endpoint only supports deprovisioning and reprovisioning records.","status":"422"

However, when receiving the following invalid body:

{"schemas": ["urn:ietf:params:scim:api:messages:2.0:PatchOp"], "Operations": [{"op":"Add","path":"displayName","value":"Norris, Chuck"}]}

the gem raises a 500 error because it's expecting "value" to contain an object not a string.

Here is a full curl request to reproduce:

curl -X PATCH 'http://dev:api_key@localhost:3000/scim/v2/Users/819216' -d '{"schemas": ["urn:ietf:params:scim:api:messages:2.0:PatchOp"], "Operations": [{"op":"Add","path":"displayName","value":"Norris, Chuck"}]}' -H 'Content-Type: application/scim+json'

To solve this, let's add more specific validation for the types of patch requests we do except currently so that we can return that 422 instead of raising a 500 error when someone supplies an invalid patch body.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions