SimpleIdServer icon indicating copy to clipboard operation
SimpleIdServer copied to clipboard

Updating/deleting a resource as part of a bulk request throws exception

Open canea-asb opened this issue 1 year ago • 1 comments

Reproduction steps

  1. Send a request with the following body to /Bulk, which creates two users:
{
    "schemas": ["urn:ietf:params:scim:api:messages:2.0:BulkRequest"],
    "Operations": [{
        "method": "POST",
        "path": "/Users",
        "bulkId": "user15",
        "data": {
            "schemas": [
                "urn:ietf:params:scim:schemas:core:2.0:User",
                "urn:ietf:params:scim:schemas:extension:enterprise:2.0:User"
            ],
            "externalId": "O9876",
            "userName": "[email protected]",
            "name": {
                "givenName": "Olivia",
                "familyName": "Johnson"
            },
            "active": "true",
            "urn:ietf:params:scim:schemas:extension:enterprise:2.0:User": {
                "department": "Marketing"
            }
        }
    },
    {
        "method": "POST",
        "path": "/Users",
        "bulkId": "user16",
        "data": {
            "schemas": [
                "urn:ietf:params:scim:schemas:core:2.0:User",
                "urn:ietf:params:scim:schemas:extension:enterprise:2.0:User"
            ],
            "externalId": "P1234",
            "userName": "[email protected]",
            "name": {
                "givenName": "Peter",
                "familyName": "Smith"
            },
            "active": "false",
            "urn:ietf:params:scim:schemas:extension:enterprise:2.0:User": {
                "department": "Procurement"
            }
        }
    }]
}
  1. Send a request with the following body to /Bulk, which updates two users: Note that you need to replace "[insert user id here]" with the IDs of the users created in step 1.
{
    "schemas": ["urn:ietf:params:scim:api:messages:2.0:BulkRequest"],
    "Operations": [{
        "method": "PUT",
        "path": "/Users/[insert user id here]",
        "bulkId": "user15",
        "data": {
            "schemas": [
                "urn:ietf:params:scim:schemas:core:2.0:User",
                "urn:ietf:params:scim:schemas:extension:enterprise:2.0:User"
            ],
            "externalId": "O9876",
            "userName": "[email protected]",
            "name": {
                "givenName": "Olivia",
                "familyName": "Swanson"
            },
            "active": "false",
            "urn:ietf:params:scim:schemas:extension:enterprise:2.0:User": {
                "department": "Marketing"
            }
        }
    },
    {
        "method": "PUT",
        "path": "/Users/[insert user id here]",
        "bulkId": "user16",
        "data": {
            "schemas": [
                "urn:ietf:params:scim:schemas:core:2.0:User",
                "urn:ietf:params:scim:schemas:extension:enterprise:2.0:User"
            ],
            "externalId": "P1234",
            "userName": "[email protected]",
            "name": {
                "givenName": "Peter",
                "familyName": "Green"
            },
            "active": "true",
            "urn:ietf:params:scim:schemas:extension:enterprise:2.0:User": {
                "department": "Procurement"
            }
        }
    }]
}

Expected outcome The users were updated according to the second bulk request.

Actual outcome The following exception is thrown:

fail: SimpleIdServer.Scim.Api.UsersController[0]
      resource  not found
      SimpleIdServer.Scim.Exceptions.SCIMNotFoundException: resource  not found
         at SimpleIdServer.Scim.Commands.Handlers.ReplaceRepresentationCommandHandler.Validate(ReplaceRepresentationCommand replaceRepresentationCommand)
         at SimpleIdServer.Scim.Commands.Handlers.ReplaceRepresentationCommandHandler.Handle(ReplaceRepresentationCommand replaceRepresentationCommand)
         at SimpleIdServer.Scim.Api.BaseApiController.InternalUpdate(String prefix, String id, RepresentationParameter representationParameter, CancellationToken cancellationToken)

Also, the SCIM server returns the following response:

{
    "schemas": [
        "urn:ietf:params:scim:api:messages:2.0:BulkResponse"
    ],
    "Operations": [
        {
            "method": "PUT",
            "bulkId": "user15",
            "status": {
                "code": 404,
                "response": {}
            }
        },
        {
            "method": "PUT",
            "bulkId": "user16",
            "status": {
                "code": 404,
                "response": {}
            }
        }
    ]
}

Note! An example project is attached to this issue that can be used to start the SCIM server that was used in the bug reproduction steps.

BugReproProject.zip

canea-asb avatar Jan 07 '25 15:01 canea-asb

"Hello,

Indeed, there is an error in the implementation 😔. For some reason, even though the id parameter is passed into the sub HTTP request, this value is not correctly transmitted by the route to the action. I have made some modifications in the project to fix this issue! https://github.com/simpleidserver/SimpleIdServer/commit/62ad8c81db09f0e51dc88b78f99bf64839e187d9

KR, SID

simpleidserver avatar Jan 08 '25 14:01 simpleidserver