Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
canea-asb opened this issue Jan 7, 2025 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@canea-asb
Copy link
Contributor

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

@simpleidserver simpleidserver self-assigned this Jan 7, 2025
@simpleidserver simpleidserver added the bug Something isn't working label Jan 7, 2025
@simpleidserver simpleidserver moved this to In Progress in Release 5.0.3 Jan 7, 2025
thabart added a commit that referenced this issue Jan 8, 2025
@simpleidserver
Copy link
Owner

"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!
62ad8c8

KR,
SID

@simpleidserver simpleidserver moved this from In Progress to Done in Release 5.0.3 Jan 8, 2025
@simpleidserver simpleidserver closed this as completed by moving to Done in Release 5.0.3 Jan 8, 2025
@simpleidserver simpleidserver reopened this Jan 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Done
Development

No branches or pull requests

2 participants